VI=VIsual Editor , it’s text editor in UNIX/Linux environment. It has two modes, (i) Command Mode : based on commands you can edit text , eg: pressing dd → will delete the entire one line. (ii) Insert Mode : whenever you enter vi (vi <filename> , by default its command mode, by pressing I you can shift into Insert mode, here you can type , copy, paste text.
| 1 | Enter into Insert mode | I |
| 2 | Enter back to command mode | esc |
| 3 | Move down line | j |
| 4 | Move up line | k |
| 5 | Move left | h |
| 6 | Move Right | l |
| 7 | Go to last line | G |
| 8 | Last Position | “ |
| 9 | Delete current character at cursor | x |
| 10 | Delete character before cursor | X |
| 11 | Replace current character | r |
| 12 | Delete current line | dd |
| 13 | Delete the current line from current character | D |
| 14 | Delete current line to end of the file | dG |
| 15 | undo | u |
| 16 | Repeat last command | . |
| 17 | Copy a line | yy |
| 18 | Paste after current line | p |
| 19 | Paste before current line | P |
| 20 | Join two lines | j |
| 21 | Repeat the current line | yyp |
| 22 | Move to next word | w |
| 23 | Move to back word | b |
| 24 | Delete one word | dw |
| 25 | Copy one word | yw |
| 26 | Search | / |
| 27 | Replace all (s: string, g:globally) | :<startLine,endLine> s/<oldString>/<newString>/g → :1,$ s/one/two/ |