A Noob's journey into ViOct 25, 2010
I am learning vi , partly because my job demands it and partly because it is a cool editor .
Things i knew already :
To open a text file in vi type
$ vi mytextfile
This is the most important part you've to get past as a beginner :
In your normal text editor , you can always write new text or delete or change text in the file you have opened .
In vi , you can be in writing mode (normal-text-editor like behavior , its called insert-mode or something) , and this is NOT the mode you'll be in once you've opened a file , when in insert mode --Insert-- will be displayed at the bottom .
To get into the insert mode you've to press i or a , now you can edit text .
For saving the file , hit the escape key to escape from the insert-mode . Now you are no longer in insert mode , type :wq yes, colon w and q . to write the file and quit from vi .
For quitting withour saving hit :q! .
Things i learned yesterday :
To delete an entire line of text get out of insert mode , move your cursor to the line you want using the arrow keys or the h j k l keys(BTW j and k are valid shortcut for same purpose in gmail and twitter ) now hit dd , and the line is gone !
Things i learned today :
I had to find some text in the file i opened , i have to first get out of the insert-mode by hitting ESC and then type / (thats a slash) followed by the word to find .Now hit enter to find the first occurrence and then hit n to move to the next occurrence .
i -- insert-mode
:wq -- write and quit
:q! -- quit without writing
/word -- search for word
n -- find next occurrence of word
dd - delete a line of text
u -- undo
Tomorrow i need to know more about copying and pasting . Heard it is powerful.
So i've got started , hoping to learn more soon .