vim: yank lines by marking section
If you ever need to cut/copy/delete/paste lines without knowing the actual number of lines, here is what you should do.
- In normal mode, go to the beginning of the section that you want to yank.
- Type
mk
to mark this spot ask
. - Go to the end of the section you want to yank using whatever movement commands you like.
Type:
y'k
(y = yank, single quote = go to mark, k) To yank from the mark to the current location. - You can paste those lines wherever you want with
p
Similarly, d'k
will cut/delete the lines from the current location to the mark.
Written by Ryan Regalado
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#