-
Notifications
You must be signed in to change notification settings - Fork 8
07. vim_gvim commands
Gopalsuthar2308 edited this page Aug 20, 2022
·
4 revisions
Note:- vim and gvim both are similar but gvim is GUI version of vim editor.
Step-1:- Run the following command from terminal.
command:- vim example.txt (general format:- vim filename.extension)

Figure.1. Creating vim file
Step-2:- vi editor window will open and it will looks like picture given below.

Figure.2. vim editor window
Step-3:- go to insert mode by pressing i from the keyboard.

Figure.3. vim editor in insert mode
Step-4:- write the contents into the file in insert mode and press esc key then type :wq for saving the contents in file and quit.
Note:- in esc mode by typing :q! command file closed without saving the contents.

Figure.4. Content in file and save
| Sr No. | Vim commands | Description |
|---|---|---|
| 1 | h | moves cursor left |
| 2 | j | moves cursor down |
| 3 | k | move cursor up |
| 4 | l | move cursor right |
| 5 | gj | move cursor down (multi-line text) |
| 6 | gk | move cursor up (multi-line text) |
| 7 | H | move to top of screen |
| 8 | M | move to middle of screen |
| 9 | L | move to bottom of screen |
| 10 | w | jump forwards to the start of a word |
| 11 | W | jump forwards to the start of a word (words can contain punctuation) |
| 12 | e | jump forwards to the end of a word |
| 13 | E | jump forwards to the end of a word (words can contain punctuation) |
| 14 | b | jump backwards to the start of a word |
| 15 | B | jump backwards to the start of a word (words can contain punctuation) |
| 16 | 0 | jump to the start of the line |
| 17 | $ | jump to the end of the line |
| 18 | gg | go to the first line of the document |
| 19 | G | go to the last line of the document |
| 20 | zz | center cursor on screen |
Tabular column.1. vim/gvim command cheat sheet
| Sr No. | Vim commands | Description |
|---|---|---|
| 1 | yy | yank (copy) a line |
| 2 | 2yy | yank (copy) 2 lines |
| 3 | yw | yank (copy) the characters of the word from the cursor position to the start of the next word |
| 4 | yiw | yank (copy) word under the cursor |
| 5 | yaw | yank (copy) word under the cursor and the space after or before it |
| 6 | y$/Y | yank (copy) to end of line |
| 7 | p | put (paste) the clipboard after cursor |
| 8 | P | put (paste) before cursor |
| 9 | gp | put (paste) the clipboard after cursor and leave cursor after the new text |
| 10 | gP | put (paste) before cursor and leave cursor after the new text |
| 11 | dd | delete (cut) a line |
| 12 | 2dd | delete (cut) 2 lines |
| 13 | dw | delete (cut) the characters of the word from the cursor position to the start of the next word |
| 14 | diw | delete (cut) word under the cursor |
| 15 | d$/D | delete (cut) to the end of the line |
| 16 | x | delete (cut) character |
Tabular column.2. cut and paste command cheat sheet
| Sr No. | Vim commands | Description |
|---|---|---|
| 1 | i | insert before the cursor |
| 2 | I | insert at the beginning of the line |
| 3 | a | insert (append) after the cursor |
| 4 | A | insert (append) at the end of the line |
| 5 | o | append (open) a new line below the current line |
| 6 | O | append (open) a new line above the current line |
| 7 | ea | insert (append) at the end of the word |
| 8 | Esc | exit insert mode |
Tabular column.3. Insert command cheat sheet
| Sr No. | Vim commands | Description |
|---|---|---|
| 1 | :h[elp] keyword | open help for keyword |
| 2 | :sav[eas] file | save file as |
| 3 | :clo[se] | close current pane |
| 4 | :ter[minal] | open a terminal window |
| 5 | K | open man page for word under the cursor |
Tabular column.4. Global command cheat sheet
Using the vim --help command user came to know vim command available options with it's description.
To learn cat command : https://github.com/muneeb-mbytes/linux_course/wiki/cat-command
- Home
- 01. pwd command
- 02. cd commands
- 03. ls commands
- 04. mkdir command
- 05. clear_command
- 06. rm_command
- 07. vim_gvim commands
- 08. cat command
- 09. echo_command echo "string"
- 10. head command
- 11. tail command
- 12. history command
- 13. mv command
- 14. cp_command
- 15. find command
- 16. grep command
- 17. vimdiff
- 18. alias and unalias
- 19. Environmental variables
- 20. df and du command
- 21. symbolic _links
- 22. ps command
- 23. kill_command
- 24. whoami
- 25. passwd command
- 26. chmod command
- 27. sed command
- GIT COMMAND CHEAT SHEET
- Overview of Linux
- Template for linux comands