Unable to add text in Vim visual mode to another file

I selected the text by visual mode and pressed :.

I execute the following command unsuccessfully

w >> ~/Documents/Test/test.java 

The result is an empty file.

How can you add text in Vim visual mode to another file?

+4
source share
1 answer

After selecting the text in visual mode and entering ":" you should see ": '<,'>" already printed for you. This means between the beginning and the end of your visual choice. You can add "w β†’ ~ / Documents / Test / test.java" after ": '<,'>". What you see before entering will be:

 :'<,'>w >> ~/Documents/Test/test.java 

If the file does not exist or you do not have the appropriate permissions, you will receive an error message, otherwise it should say β€œadded” and work. I tested this and it works on Vim 7.2.

+11
source

All Articles