VI Editor:
vi is a screen-oriented text editor originally created for the
Unix operating system. The portable subset of the behavior of vi and
programs based on it, and the ex editor language supported within these
programs, is described by (and thus standardized by) the Single Unix
Specification and POSIX.
VI/VIM EDITOR:
vi file.txt(edit file with vi editor)
vi
-r file.txt(recover filename that was being edited when
system crashed)
1. VI Modes:
Modes key
- Command Esc
- Insert i, I, a, A
- Line :
2. vi Insert Mode:
- i - Insert at the curser position
- I - Insert at the beginning of the line
- a - Append after the curser position
- A - Append at the end if the line
- o - Open a new line below the current line
- O - Open a new line above the current line
3. vi Navigation:
- k or up-arrow - Up one line
- j or dawn-arrow - Down one line
- h or left-arrow - Left one character
- l or right-arrow - Right one character
- w - Right one word
- b - Left one word
- ^ - Goto the beginning of the line
- $ - Goto the end of the line
- :w - Writes (saves) the file
- :w! - Force the file to be saved
- :q - Quit
- :q! - Quit without saving changes
- :wq! - Write and quit
- :x - Same as :wq
- :n - Position the curser at line n
- :set nu - Turn on line numbering
- :set nonu - Turn off line numbering
- :help [sub command] - Get help
Repeat a command by preceding it with a number
- 5k - Move up to line 5 times
- 80i <text> <esc> - Insert text 80 times
6. vi Delet Text:
- x - Delete single character under cursor
- nx - Delete n characters, starting with character under cursor
- dw - Delete the single word beginning with character under cursor
- dnw - Delete N words beginning with character under cursor;e.g.,d5w deletes 5word
- dd - Delete entire current line
- D - Delete the remainder of the line, starting with current cursor position
- r - Replace the current character
- cw - Change the current word
- cc - Change the current line
- c$ - Change the text from the current position
- ~ - Reverse the case of character
8. vi Copying and Pasting:
- yy - Copy (yank) the current line
- P - Paste before curser
- p - Paste after curser
- u - Undo
- ctrl + r - Redo
10. vi
Searching:
- / <pattern> - Forward search for {pattern}
- ? <pattern> - Reverse search for {pattern}
- n - Repeat the last search
- N - Repeat the last search in the opposite direction
VI TEXT EDITOR BASIC COMMANDS
Reviewed by vijay pratap singh
on
April 01, 2017
Rating:
No comments: