Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
May 22, 2022 04:27 pm GMT

Top 15 Vim shortcuts to remember

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 :

In this blog, I'll list down 15 shortcuts that will save you a lot of time while working with vim.

Shortcut keyFunction
wTo move forward by one word(you need to be in command mode).
bTo move backward by one word(you need to be in command mode).
ggTo move to the beginning of the file.
GTo move to the end of the file(last line).
dwTo delete the word, cursor is positioned upon.
ddTo delete the line, cursor is positioned upon.
d2dTo delete 2 lines, starting from the line, the cursor is upon.
You can replace '2' by any number and delete any number of lines.
uTo undo the last operation performed.
Ctrl+rTo redo the last operation performed.
/sample_textTo search for the 'sample_text' in the file. Use n to move to next occurrence and N to move to the previous occurrence of the text.
:%s/old/newReplace all the occurrences of the old text with new text.
:q!To quit the file discarding all the changes made to the file.
:wqTo save the file and quit.
:w To save the file with filename 'sample_filename'.
:qTo quit Vim(Fails when changes has been made to file).

That's all for the blog. I hope you had good time reading the blog!


Original Link: https://dev.to/kcdchennai/top-15-vim-shortcuts-to-remember-5523

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To