Vi- A editor that is very frequently used in linux/unix for editing some doc or file. It just like a notepad in window. But its so smater then notepad :)
Basic "vi" features
One edits a file in vi by issuing the command: vi file-to-edit.txt
The vi editor has three modes, command mode, insert mode and command line mode.
like $vi file-to-edit.txt
then apply all command listed below:-
Editing commands:
I hope you like this blog :)
Vishal Lakhmapurkar
Basic "vi" features
One edits a file in vi by issuing the command: vi file-to-edit.txt
The vi editor has three modes, command mode, insert mode and command line mode.
- Command mode: letters or sequence of letters interactively command vi. Commands are case sensitive. The ESC key can end a command.
- Insert mode: Text is inserted. The ESC key ends insert mode and returns you to command mode. One can enter insert mode with the "i" (insert), "a" (insert after), "A" (insert at end of line), "o" (open new line after current line) or "O" (Open line above current line) commands.
- Command line mode: One enters this mode by typing ":" which puts the command line entry at the foot of the screen.
like $vi file-to-edit.txt
then apply all command listed below:-
Editing commands:
-
Keystrokes Action i Insert at cursor a Append after cursor A Append at end of line ESC Terminate insert mode u Undo last change U Undo all changes to entire line o Open a new line dd
3ddDelete line
Delete 3 lines.D Delete contents of line after cursor C Delete contents of line after cursor and insert new text. Press esc key to end insertion. dw
4dwDelete word
Delete 4 wordscw Change word x Delete character at cursor r Replace character R Overwrite characters from cursor onward s Substitute one character under cursor continue to insert S Substitute entire line and begin to insert at beginning of line ~ Change case of individual character ctrl-a
ctrl-xIncrement number under the cursor.
Decrement number under the cursor./search_string{CR} Search for search_string ?search_string{CR} Search backwards (up in file) for search_string /\<search_string\>{CR} Search for search_word
Ex: /\<s\>
Search for variable "s" but ignore declaration "string" or words containing "s". This will find "string s;", "s = fn(x);", "x = fn(s);", etcn Find next occurrence of search_word N Find previous occurrence of search_word . repeat last command action.
- Use command: ZZ
Save changes and quit. - Use command line: ":wq"
Save (write) changes and quit. - Use command line: ":w"
Save (write) changes without quitting. - Use command line: ":q!"
Ignore changes and quit. No changes from last write will be saved. - Use command line: ":qa"
Quit all files opened.
I hope you like this blog :)
Vishal Lakhmapurkar
No comments:
Post a Comment