Vim: Copy/paste selection in new file
Do you usually select text in vim then yank it with y
, open a new file and paste the selection with p
?
Stop wasting your time!
To copy selection in new file just use the usual write command :w
when in Visual mode (vim will automatically add the range to your command line, resulting in : '<,'>w newfile
)
To cut and paste a selection in a new file: enter Visual mode and select what you want, then hit :
and type !cat > newfile
resulting in : '<,'>:!cat > newfile
Written by Lorenzo Novaro
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Related Tags
#vim
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#