Copy and paste in vi + some other tips

vim-editor_logo-300x300

I use vi a lot at work.  It really became a lot more useful when I figured out how to copy and paste blocks of code.

All of these are done in command mode:

shift-v =  select a line
ctrl-v = select a rectangle
Y = yank selection to buffer
P = paste from buffer before cursor
p = paste from buffer after cursor position
dd = delete a line (this also moves the line to the buffer, so you can still paste it)

Here are some other handy ones:

u = convert a selection to lowercase
u = undo previous action (if nothing is selected)
ctrl-R = redo an action
gg = go to the top of the document
G = go to the end of the document
###gg = go to line number ###
:%s/blah/whee/gc = replace “blah” with “whee” globally with confirmation
:%r~/whee.txt = insert text into the current document from a file (~ = your home directory)

(Visited 13 times, 1 visits today)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments