Post

chad vim

THE NEOVIM EDITOR

vim is an awesome editor. fast, lightweight and mouse freeee
vim motion is the way to use vim like the keybinding and all so we will cover all that here.

VIM MODES

vim has 4 Modes
to change one mode from other, you need to escape from the current mode by pressing esc key and then the key for the mode you want to change.
for example if you are in insert mode and you want to go into visual mode. first press esc to get out of visual mode then v for visual mode.

  1. normal mode - the first mode when you enter into any file.
  2. insert mode - where you can write anything. press i for insert mode.
  3. visual mode - where you get a visual block for varius functions, press v for visual mode.
  4. command mode - where you can type commands. press : for this.

how to move in vim

first the basic movements of vim are h,j,k,l H - left
J - down K - up L - right

you can use number with these keys to go that way that many times like 16h with go 16times left or 14j would go 14times down so pretty fast yk

word by word

W - forward B - backward

delete

dd - delete the whole line

dd can be combined with numbers and w, b

u - undo

ctrl +r - redo

copy

go into visual mode and simply hjkl to select your stuffs

y - yank (copy)

p - paste

shift + p - new line paste

delete and yank both goes in same buffer so you paste what you yank or delete

_ - goes to begening of the line

$ - to the last of line

tips tricks shits

x - delete one word

ddp - swap upper and lower line

di” - delete inside “”

yi” - copy inside quote

dG - delete everything

dgg - delete everything

ctrl + w - delete prev word in insert mode

ctrl + u - delete everything from cursor to back

ctrl + o - run normal mode command in insert for for once

= - indent or reindent , can be combined with gg goes

n - go to next instance of a word in find

shift + n - just backward

%s/what-to-change/change into what/g - multiple find and replace

s/what-to-change/change into what/g - multiple find and replace in that line

here / is delimeter which can be changed if u wanna edit /

This post is licensed under CC BY 4.0 by the author.