vi editor is a default editor of all Unix systems. It has several modes. Make sure that your terminal has correct settings, vt100 emulation works good if you are logged in using pc.
- i for insert mode.
- I inserts text at the curson
- A appends text at the end of the line.
- a appends text after cursor.
- O open a new line of text above the curson.
- o open a new line of text below the curson.
- : for command mode.
- <escape> to invoke command mode from insert mode.
- :!sh to run unix commands.
- x to delete a single character.
- dd to delete an entire line
- ndd to delete n number of lines.
- d$ to delete from cursor to end of line.
- yy to copy a line to buffer.
- P to paste text from buffer.
- nyy copy n number of lines to buffer.
- :%s/stringA/stringb /g to replace stringA with stringB in whole file.
- G to go to last line in file.
- 1G to go to the first line in file.
- w to move forward to next word.
- b to move backwards to next word.
- $ to move to the end of line.
- J join a line with the one below it.
- /string to search string in file.
- n to search for next occurence of string.
Once you are done typing then to be in command mode where you can write/search/ you need to hit :w
filename to write, and in case you are done writing and want to exit :w!
will write and exit.
Post a Comment