The VI or VIM is a terminal text editor used on many unix/linux systems. It is widely used and very useful.
With little expirience and few learned tricks, It can enhance Your productivity. It has some very interesting features that
can definately help You to write Your code faster. To enter VI, in command line prompt enter "vi" with the name of a file You want to edit. Once VI is lunched, simply press "Esc" to enter in user mode, and press"i" to start inserting text:
Once done, You can save a file by "Esc" - entering command mode, after which follows command to save/write and quit ":wq!":
If just want to quit from VI without saving, use "q!". Ragarding the function You want, VI have large number of commands that can be entered in command mode.
Command mode can be entered by pressing "Esc" and ":".
Some usefull commands that can be entered in command mode are:
":w" - Write out the current file (save).
":wq!" - Write out the current file and quit.
":q!" - Quit VI without saving changes.
":/string" - Search for a string in a file.
":s/pattern/to_pattern/g" - Substitutes the specified pattern with the string in the to_pattern.
(If a 'g' is specified, then all occurences are substituted)
":nu" - Shows the number of a current line.
":g/string" - Finds all string ocurences in a file.
Simply by entering "Esc" You enter in user mode.
Some usefull commands that can be entered in user mode for start are:
"a" - enter insert mode, the characters typed in will be inserted after the current cursor position.
"h" - move the cursor to the left one character position.
"i" - enter insert mode, the characters typed in will be inserted before the current cursor position.
"j" - move the cursor down one line.
"k" - move the cursor up one line.
"l" - move the cursor to the right one character position.
"r" - replace one character under the cursor. Specify count to replace a number of characters.
"u" - undo the last change to the file. Typing u again will re-do the change.
"x" - delete character under the cursor.
"A" - Append at the end of the current line.
"I" - Insert from the beginning of a line.
"dd" - Deletes the line in which cursor is located.
"D" - Deletes the text from the cursos to the right end of a line.
"G" - Goes to the end of a file.
"0" - Goes to the begginging of a file.
Comments
Post a Comment