Skip to main content

Posts

Showing posts with the label vim

Copy/Paste the block of text in vi/vim

Mark the location of the first character of the block of text you want to copy by pressing mx This marks the begining of the text to be copied into a buffer 'x'. Move the cursor over the last character of the block of text you want to copy and press (shift)+x By pressing shift you are moving all the characters from mark to the current position into a buffer. To copy (or, in vi terminology, to yank the buffered text) press y'x This will yank everything from the buffer x. ('tick' character ' is command in vi to read from the named buffer) Now move the cursor above the location where you want to paste the yanked text and press p p (for paste) will insert the copied (yanked) text at the line below the cursor.

[vi/vim] Save on Exit

I see a lot of people using 'wq' a lot but never a form 'x'. In vi and vim, if you want to save and exit with a simple key stroke simply use: :x