Sitemap

Vim Editor Personal Note

2 min readOct 25, 2022

--

Insert Mode Commands

i -> will append text before the cursor point

I -> will append text from the start point of the current line

a -> will append text after the cursor

A -> will append text the end of the current line

o -> will append the text after below of the current line

O -> will append new line above of the current line

u -> will undo the recent changes

Ctrl + r -> will redo the changes

dd -> will cut a line

ndd -> will cut n number of lines. Example 10dd will cut the 10 line from the current cursor point

V -> select the whole line (then you can use arrow key to select)

Ctrl+v -> select rectangular block (then you can use arrow key to select)

y-> Copy the selected text

p -> will paste the copy/cut lines below the cursor

P -> will paste the copy/cut lines above the cursor

/search_text -> will search inside the file (n-> for next match, N-> for previous match)

G or shift+g-> will bring last of the file

gg -> will bring beginning of the file (or :1 )

Get MSI Shafik’s stories in your inbox

Join Medium for free to get updates from this writer.

?search_text -> search from the end line

* -> asterisk will help to search the next occurrence of the current cursor’s word. (If the cursor is on the word “yes”, then if you press asterisk(*) then it will move to the next “yes” of the file.

# -> same asterisk, just help to search previous occurrence of the current cursor’s word.

Last Line Mode Commands:

:q! -> quit without saving

:w! -> save the file

:wq! -> save and quit (shortcut Shift+ZZ)

:!any command -> to run any shell command from vim (example: :!ls will be shown the current directory’s file list)

:%s/search_string/new_string/g -> to replace the search pattern with the new text. Example: :%s/none/true/g will replace all “none” with “true”.

:e! -> will remove all the changes till last save.

:set nu -> will show the line numbers (you can write this command on .vimrc file to run this command every time vim opening)

:line_number -> will bring you to the specific line. Example- :30 will bring you to the line number 30

:set nonu -> will not show the line numbers

:syntax on -> will enable syntax highlighting

: syntax off -> will disable syntax highlighting

Work with multiple files:

vim a.txt b.txt -> will open the file a.txt and b.txt at the same time. You can switch the file using :n (next) or :N(previous)

vim -o a.txt b.txt -> will split the terminal for displaying both files (use Ctrl+w to move between the files)

vim -d a.txt b.txt -> will display the differences of the files

(Personal blog- https://eshafik.wordpress.com/2022/10/25/vim-editor-personal-note/)

--

--