vi question
if I have 2 files, how do I copy a section of one file to the other?
all I know is "yy" for copy and "p" to paste, but that can only be done in same file. |
Also another question about replacement.
How do I replace all string in a file by the other. right now I use :s1,lastline/oldstring/newstring/g but the problem is I need to always know the number of line in the file before I can do replacement. Any faster way? |
1. If you use vim, you can have multiple files opened in the same time and copying and pasting operations work fine between them.
2. :%s/oldstring/newstring/g % means all lines in the file |
If opening two (or more) files is not an option, you can do the following.
You have opened the 'master' file and are in command mode: r!sed -n '2,4p' /etc/passwd This will put lines 2,3 and 4 from the passwd file into the file you are editing, below the cursor position. |
A great program that comes with vim is vimtutor,try it from the command line.
|
All times are GMT -5. The time now is 04:25 PM. |