# 8 Shortcuts To Get Started With Vim

Vim has too many shortcuts and it can be confusing 😵‍💫 for newcomers. So, I comprised a list of 8 shortcuts from the perspective of a person coming from normal text editors ⌨️. 

For the people who are asking why not just go through Vim Tutor? Vim tutor is easy but It has too many shortcuts to wrap our mind around. Normally We don't use all of them all the time so learning all at the same time is not productive as we will eventually forget😵 them!

To develop the 💪🧠 muscle memory, first we have to work with these limited shortcuts.

So, let's get started!! 🥳

![CatTypingGIF.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1665066425758/d4ahHsKmZ.gif align="center")

## 📝 Prerequisites:
- Any Vim editor Or VS Code with Vim extension (I will be using this)

## 🔴 Before the shortcuts:

Vim has three text modes:
1. Normal mode - Where you will use the vim shortcuts
2. Insert mode - Where you can actually edit the text with normal keystrokes
3. Visual mode - Where you will select the text

## 🔄️How to switch between modes:
- ```Escape``` to exit current text mode or to enter Normal mode
- ```i``` to enter Insert Mode
- ```v``` to enter Visual Mode

%[https://www.youtube.com/watch?v=hTbvtak47wk]

> Look at the status bar at the bottom to know which mode you currently in.

## ⌨️ Shortcuts:

### 🧭 1. Navigate cursor in Normal mode:
In Vim, we use h, j, k, l to navigate between lines.
- 👉 ```h``` for moving right   
- 👈 ```l``` for moving left     
- 👇 ```j``` for moving down  
- 👆 ```k``` for moving up      

%[https://www.youtube.com/watch?v=M8RbnOi_R-w]

### 📝 2. Edit Text 
First enter Insert mode using ```i```. That's it! Now Text is editable normally.<br>
Use ```Escape``` to exit Insert mode.

%[https://www.youtube.com/watch?v=Wlq3qLfJd4w]

### 🏁 3. Navigate to start or end of the line in normal mode
- ```shift+6``` or ```^``` to get to the start of the line or the first non-blank character
- ```shift+4``` or ```$``` to get the end of the line
- ```shift+a``` to append to the end of the line and switch to insert mode 

%[https://www.youtube.com/watch?v=yZM00JHy_AE]

### 🔚 4. Going to the end or beginning of the file: 

- ```shift + g``` or ```G``` - to go to last line of the file
- ```gg``` - to go to the first line of the file

%[https://www.youtube.com/watch?v=I3P82xdeUqI]

### ↩️ 5. Undo or Redo changes in file

- ```u``` to undo changes
- ```ctrl + r``` to redo changes

%[https://www.youtube.com/watch?v=9EB1bs_7DaM]

### 🔍 6. Search text 

- ```/``` followed by the text you are searching for
  - ```n``` - to go to next occurrence
  - ```shift+n``` - to go to previous occurrence 

%[https://www.youtube.com/watch?v=y5apc3rXDhY]

### 🔁 7. Replace text 
- ```:%s/text1/text2/g``` - replace text1 with word you want to change and text2 is the replacement word
  -  add ```c``` to the end like ```:%s/text1/text2/gc``` to confirm every replacement
    - For every replacement you get to these options
      1. ```y``` for replacing the current entry
      2. ```n``` to not replace the current entry and skips to next entry
      3. ```a``` to change all entries
      4. ```q``` to quit 
      5. ```l``` replace only the first entry and quit

%[https://www.youtube.com/watch?v=ni9tQMc45hk]

### 💾 8. Save and quitting vim
- ```shift+zz``` or ```:wq!``` - save and exit the file
- ```:q!``` - exit file without saving

%[https://www.youtube.com/watch?v=7ViV_UzpblM]

Tada!! You are done.

![mission complete](https://cdn.hashnode.com/res/hashnode/image/upload/v1665086572309/ZnCKV7_i-.gif align="center")

Liked my article? Give a thumps up!!
Have some feedbacks? Comment them below!!

