14.06.2014 Views

vim 101 hacks

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Transaction ID: 85W16630AD8515549<br />

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

www.thegeekstuff.com<br />

Chapter 7: Expert Text Manipulation<br />

Hack 35. Copy Lines to Named Buffer for Later Use<br />

You can copy (yank) lines to a named buffer, which you can use later as<br />

shown below.<br />

Valid named buffer: a to z (26 total valid named buffers)<br />

Command<br />

“ayy<br />

Description<br />

Copy current line to buffer “a”<br />

“a5yy<br />

Copy 5 lines to buffer “a”<br />

“ap<br />

Paste copied lines from buffer “a” after the cursor<br />

“aP<br />

Paste copied lines from buffer “a” before the<br />

cursor<br />

Hack 36. Convert Inserted Text to Normal Mode<br />

Commands<br />

Have you ever typed a normal mode command when you are in insert mode<br />

by mistake? This hack is very helpful under those situations as shown below.<br />

• Assume that you have the following text inside Vim editor – john<br />

• You wanted to change john to Jason.<br />

• You forgot that you are insert mode and typed the following –<br />

cwjasonjohn<br />

65

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

Saved successfully!

Ooh no, something went wrong!