Vi - Editor

Well, when it comes to text file editing in a Linux terminal window, there really is nothing better than Vi. However, if I have a GUI, then UltraEdit is my clear favourite.

The advantage of learning Vi is that every Linux box has it and it runs in the terminal so is everywhere. The thing with Vi is remembering all the commands, master them and editing is quick and easy, forget them and life is a pain! Yes, I confess, sometimes it is just easier to edit the file via FTP. However there is a lot to be said for learning Vi, one good starting point is vi Tutorial, and another is Interactive Vim tutorial. What follows is the Vi commands that I use:

KeystrokeAction
Shift GGo to end of file
:$Goto end of file
:nGoto line n
Ctrl+fMove forward 1 "page or screen"
Ctrl+bMove backward 1 "page or screen"
Ctrl+dMove forward ½ "page or screen"
Ctrl+uMove backward ½ "page or screen"
:.=Show current line number
/aaaSearch for text aaa, following by n for next or N for previous
?aaaSearch backwards for text aaa, following by n for next or N for previous
:1,$!sortSort the file (done using external command)
OOpen a new line above the cursor
oOpen a new line below the cursor
0Move to start of current line (zero)
$Move to end of current line
wMove to next "word"
AAppend to the end of the current line
aAppend after the current character
iInsert before the current character
YYank, or copy the current line
PPut, or paste the yank'ed line
xDelete current character
ddDelete current line
Shift DDelete from cursor to end of line
:wqSave changes and exit
:xExit, saving changed if any were made
:q!Exit and don't save changes
:set nuShow line numbers!
:s/charsSearch for the entered chars
:s/old/newSearch and replace on the current line
:%s/old/newSearch and replace over the whole file

There is a lot more, if you start using it a lot but that is more than enough to get you started and enable you to do the basic editing.