17 Vim shortcuts that wonβt hurt learning π
git add .
git commit
<enter>
BOOMMMMMβ¦..
Some random black screen, where you canβt write nor exitπ€¨
Did this remind you of something ?π
Well, you are not alone here, most developers have passed through this phase. And that pro feeling when you are finally able to crack how to exit VIM π.
Okay Okay, enough of VIM jokes π€«
With plenty of Shortcuts/Motions of VIM, it can probably save a few seconds of your life, and make you cool among friends.π
So with that motivation π let's dive into some VIM motions.
Note: Donβt learn these at one go, try one of the shortcuts daily in your work and increase your count so as not to feel overwhelmed.
A. Basic Navigation (j,k,h,l)
1. Down: j
2. Up: k
3. Left: h
4. Right: l
B. Navigate Word by Word:
5. w
C. Reach the Top or Bottom of the file
6. Top: gg
7. Bottom: G <-- Uppercase G (Shift + G)
D. Insert ( i, a, o )
8. To insert left of the cursor: i
9. To insert left of the line: I10. To insert right of the cursor: a
11. To insert right of the current line: A <--- I love this π12. To insert at the start of the new line: o <--- I love this more ππ
E. Undo the changes
13. u
F. Delete the whole line
14. dd
Bonus: 5dd <-- to delete 5lines below
G. Delete single word
15. dw
H. Copy Paste line
16. yy pyy <-- copy (yank) current line
p <-- paste to the line below cursor
P <-- paste to the line above cursor
H. Select Line
17. Shift + V-> It will select the current lineBonus: Navigate to other lines using j,k, and press d to delete or y to copy, etc.
Congratulations on making yourself here π π
Just follow one shortcut daily, don't rush yourself, take your time and eventually, you will get the hang of it.
I hope you learned something new today.
I will be back with more such content. πππ
Letβs exit this article in the VIM way
:q! <--- exit vim and discard the change
:wq <--- exit vim and write the change
That's the end of the article.
Remember to reiterate.
πππ