Introduction
If you ever installed Linux in your life, I'm sure you might have come across Vim.
Vim is a command-line based text editor. It's a great tool but I won't say that it's the best text editor in Linux as it would lead to a never-ending debate. 
Vim is actually an improved version of the old vi editor. It comes with many new features including multi-level undo, multiple window support, visual mode and command-line completion.
If you're using it for the first time, you may have hard time trying to exit Vim.
.
.
.
What? Don't you believe me? 
Here's the proof :
 Stack Overflow@stackoverflow
Stack Overflow@stackoverflow Stack Overflow launched in 2008, demonstrating what’s possible with the internet: an open community that gives people knowledge at their fingertips.
Stack Overflow launched in 2008, demonstrating what’s possible with the internet: an open community that gives people knowledge at their fingertips.
Since then, over 1.8M people have visited us just to learn how to exit Vim. #Web30 #ForTheWeb
stackoverflow.com/questions/1182…02:00 AM - 13 Mar 2019
In this blog, I'll list down 15 shortcuts that will save you a lot of time while working with vim.
| Shortcut key | Function | 
|---|---|
| w | To move forwardby one word(you need to be in normal mode). | 
| b | To move backwardby one word(you need to be in normal mode). | 
| gg | To move to the beginningof the file. | 
| G | To move to the endof the file(last line). | 
| dw | To delete the word, cursor is positioned upon. | 
| dd | To delete the line, cursor is positioned upon. | 
| d2d | To delete 2 lines, starting from the line, the cursor is upon.You can replace '2' by any number and delete any number of lines. | 
| u | To undothe last operation performed. | 
| Ctrl+r | To redothe last operation performed. | 
| /sample_text | To searchfor the 'sample_text' in the file. Usento move to next occurrence andNto move to the previous occurrence of the text(in Command mode). | 
| :%s/old/new/g | Replacesall the occurrences of theoldtext withnewtext(in Command mode). | 
| :q! | To quit the file discarding all the changesmade to the file(in Command mode). | 
| :wq | To save the fileandquit(in Command mode). | 
| :w sample_filename | To savethe file with filename 'sample_filename'(in Command mode). | 
| :q | To quitVim. It fails when changes has been made to file(in Command mode). | 
That's all for the blog. I hope you had good time reading the blog!😃
 
Top comments (2)
@sneh274 Very helpful! Thank you for sharing :)
Glad you liked it!😃