Beginners guide to start using Vim
Tags: vim, productivity, cheatsheet, editor
Published: 2022-09-27 18:22:24

## Hello Vim !

This blog or you can say cheat-sheet covers the basic commands/keys you need to know to start using Vim. Initially, you will feel that it's a lot to remember but just **keep practicing**. The first day you'll hate it. In a week you'll understand it and by a month you'll start loving it.

The best way to utilize this cheat-sheet is to open/create a file via Vim and practice these commands one by one.  

So lets begin 🚀  

### Exiting  

`:w`  -	 save file  
`:wq` -	 save and quit (can also use `:x`)  
`:q`  -	 quit   
`:q!` -	 quit without save  
`:qa!` - close all files and abandon changes
`ZZ` - save and quit

---

### Navigating  

arrows - to navigate up down left right  
`l` -    right  
`h` -   left  
`j` -    down   
`k` -   up    

#### <u>Document  </u>

`}` -	 move down 1 block of code  
`{` -	 move up 1 block of code  
`gg` -	 move to top of file  
`G` -	 move to bottom of file  
`:<num>` - go to line `<num>`

#### <u>Words  </u>

`w` -	 move to next word on the line  
`b` -	 move to previous word on the line  
`ge` - move to previous end of word
`e` -	 move to next end of word  

#### <u>Line  </u>

`0`(zero) -move to beginning of the line  
`$` -	 move to end of the line  
`^` -	 move to first character of the line    
`t<char>` - move cursor just before `<char>` on the line  
`f<char>` - move cursor on the `<char>` on the line  
`%` -	  move cursor to matching ),], or }  

---

### Clipboard 

`x` - delete character
`<num>x` - delete `<num>` characters to right of cursor  
`dd` -	 delete current line(cut)
`yy` - yank line(copy)    
`p` -	 paste below   
`P` - 	 paste above  
`u` - 	 undo  
`ctrl R` - redo 

--- 
### Modes 

`i`      - enter insert mode  
`esc` - escape any mode and enter command mode  
`o` -	 insert 1 line below and enter insert mode  
`O` -	 insert 1 line above and enter insert mode  

`V`      -    visual mode (selects 1 line per movement)  
`v`      -    visual mode (selects 1 letter per movement)  
`V + d`  -    delete selected part  
`ctrl V + movements` - selects column  

---  

### Misc Operators and combos  

`cw` - change word -> it deletes a word and enters insert mode  
`dw` - delete to next word  
`db` - delete to beginning of word
`D` -  deletes everything to right of cursor  
`C` -  deletes everything to right of cursor and enter insert mode  

`dt<char>` - delete till `<char>` excluding `<char>`  
`ct<char>` - delete till `<char>` excluding `<char>` and enter insert mode  

`*` - toggle between instances of the word where the cursor is present  

`t<char>;` - move to `<char>` on the line on every press of `;`  

`zz` - scrolls the page such that the line on which the cursor is right now is brought to center of page...i.e. centers the work page  

`0w` - move to first character of line  
`d<num>w` - delete `<num>` words  


`a` - move right by 1 letter and enter insert mode  
`A` - move to end of line and enter insert mode   

`~` - toggle case of word (uppercase/lowercase)  

`.` - re runs the last command  

`r<anything>` - replace current letter to `<anything>`

`>>` - indent current line  
`<<` - remove indent from current line  

-------  

### Wrap Up  

There is a lot that I haven't covered yet like macros, complex combos, plugin setup, configuring vim and many other keybindings. This blog is just meant to be for beginners. Once you get comfortable with Vim it's easy to explore these and try it out.

I hope you found this cheat-sheet helpful and keep it handy for a quick reference. If you want me to add more information in this blog or need any help let me know in the comments.

Let's connect on [LinkedIn](https://www.linkedin.com/in/audarya-uttarwar/)

👋 Thanks for reading, See you next time.