14.06.2014 Views

vim 101 hacks

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Buyer: xiujuan lu (luxiujuan@gmail.com)<br />

Transaction ID: 85W16630AD8515549<br />

Vim <strong>101</strong> Hacks<br />

www.thegeekstuff.com<br />

• Pattern to Replace – \=submatch(0) + 1 – gets the matched pattern<br />

and adds 1 to it.<br />

• Flag – as there is no flag, by default it substitutes only the first<br />

occurrence in each line.<br />

After executing the substitute statement the file will look like this; then you<br />

can add the 3rd Article.<br />

vi / <strong>vim</strong> tips & tricks series<br />

Article 1: Vi and Vim Editor: 3 Steps To Enable Thesaurus Option<br />

Article 2: Vim Autocommand: 3 Steps to Add Custom Header To Your File<br />

Article 4: 5 Awesome Examples For Automatic Word Completion Using CTRL-X<br />

Article 5: Vi and Vim Macro Tutorial: How To Record and Play<br />

Article 6: Tutorial: Make Vim as Your C/C++ IDE Using c.<strong>vim</strong> Plugin<br />

Article 7: How To Add Bookmarks Inside Vim Editor<br />

Article 8: Make Vim as Your Bash-IDE Using bash-support Plugin<br />

Article 9: 3 Powerful Musketeers Of Vim Editor ? Macro, Mark and Map<br />

Article 10: 8 Essential Vim Editor Navigation Fundamentals<br />

Article 11: Vim Editor: How to Correct Spelling Mistakes Automatically<br />

Article 12: Transfer the Power of Vim Editor to Thunderbird for Email<br />

Article 13: Convert Vim Editor to Beautiful Source Code Browser<br />

Example 12. Capitalizing the first character of every sentence.<br />

When formatting a document, properly capitalizing sentences is quite useful.<br />

This can be done easily with the following substitution.<br />

:%s/\.\s*\w/\=toupper(submatch(0))/g<br />

• \.\s*\w – Search Pattern – a literal . ( period ) followed by zero or<br />

more spaces, then a word character.<br />

• toupper – converts the given text to upper case.<br />

• submatch(0) – returns the matched pattern.<br />

Text before substitution:<br />

Lot of vi/<strong>vim</strong> tips and tricks are available at thegeekstuff.com. reading<br />

136

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!