Categories: Development Tools

50 Useful Vim Commands basic to pro

In short, Vim is simply a text editor. Vim is unique and special among others because it’s a command-line text editor. Vim as a text editor is popularly used today because of its ubiquity and efficiency.

The amazing text editor works faster so users don’t waste unnecessary time writing programs. In addition, you have got to love the fact that there are many wonderful features associated with the editor.

It is a free and open-source text editor that is so compatible with many platforms. That is to say, it supports Linux, Windows, macOS, iOS, Unix, AmigaOS, MorphOS, MS-DOS, and NT.

How well do you know the key commands in Vim? Certainly, you have got to know how to use some important commands in Vim to enhance and make your coding life easy with the text editor. Every command in this article is concerned with various modes in Vim: command mode, visual mode, and insert mode. Never worry yourself as a beginner, we will give you some top Vim commands to help yourself familiarise with the text editor.

1. X

You use the X-command to get rid of unwanted characters.

X

2. CTR-R

The CTR-R command is simply used to perform redo.

CTR-R

3. A

The A-command is simply used for appending texts at the end.

A

4. dw

This gives you the opportunity to place the cursor at the starting point of a text to completely remove the text.

dw

5. 2w

This simply helps to move the cursor two words forward.

2w

6. :wq

Users are allowed to use this command if they just want to save their work and exit the text editor.

:wq

7. :q!

This command helps to nullify changes if we later think that the changes ain’t needed.

:q!

8. 0

This zero (0) command is all you need if you want to get to the starting point of a line.

0

9. dd

So the dd-command is there for you if you want to delete the line you don’t longer want.

dd

10. 2dd

This is different from the command we have explained above.

2dd

Features:

  • That is to say, 2dd-command will help you delete to the line you want.

11. d2w

In short, d2w simply stands for delete 2 words.

d2w

12. p

This is efficient for putting the cursor behind the formerly deleted text.

p

13. r

Users can use the r-command for replacing a letter.

r

Features:

  • For example, simply enter rh to replace a letter with h.

14. ce

This is used for making changes until it gets to the end of the word.

ce

15. G

The G-command is used for getting to see the bottom of a file.

G

16. gg

This does exactly the opposite of what the above command does.

gg

Features:

  • That is to say, it’s used for moving to the beginning of the file of your choice.

17. %

The %-command is at your disposal any time you are looking for a matching bracket. For example, ),], or }.

%

18. :s/old/new/g

Most importantly, any time g is globally, you are always free to change “new” for “old“.

:s/old/new/new/g

19. :!

This command is used for executing shell commands.

:!

Features:

  • For example, :!dir, :!ls.

20. R

The R-command helps you to replace multiple characters.

R

21. / backward search n

This is used for finding the next occurrence.

/backward search n

22. / backward search N

This is somehow related to the above command but it searches in the opposite direction.

/ backward search N

23. ?

Users use this command for performing a forward search.

?

24. y

In conclusion, this is an operator for copying texts through the use of v visual mode and p for pasting it.

y

25. yw

Use this command if you want to (copy) yank a word.

yw

26. a

This command is used for inserting texts after the cursor.

a

27. o

The o-command is used for opening a line below the cursor and activating the insert mode.

o

28. O

This does the opposite of the o-command explained above.

O

Features:

  • That is to say, it opens a line above the cursor.

29. e

This is simply used for moving a command to the end of a word.

e

30. ctr-w

So, if you want inter-switch from one window to another use this command.

ctr-w

31. :q

The :q-command for quitting the text editor.

:q

32. i

Most importantly, there are many modes in Vim so, therefore, the i-command is used for entering the insert mode.

i

33. h

In short, there are different commands users are allowed to use in navigating inside the Vim text editor.

h

Features:

  • Therefore, the h-command is used for navigating to the left.

34. j

This is used for navigating down.

j

35. k

k-command is called upon when users want to navigate in an upwardly.

k

36. l

This is a small letter L. To sum up, the command here is used for navigating in the right direction.

l

37. ctrl-d

This is simply used for moving down a half-page.

ctrl-d

38. ctrl-u

This is simply the exact opposite of the command described above.

ctrl-u

Features:

  • That is to say, the command here is used for moving up a half-page.

39. yy

Above all, the term yank in Vim is used instead of the word “copy” but both mean the same thing. So, therefore, users make use of yy-command to yank the current line.

yy

40. p

The p-command is there for you to use so you can paste the last thing you have copied at the cursor.

p

41. 10dd

If you want to delete more than a line but let’s say 10 lines. The 10dd-command is used fir deleting 10 lines.

10dd

42. 5x

This comes handy for deleting 5 characters ahead of the cursor.

5x

43. 100p

This is so useful for pasting a particular thing 100 times.

100p

44. :s/old/new/gc

This works in a similar way as the “:s/old/new/g” command but it confirms every time before replacing.

:s/old/new/gc

45. /search_term

It is used for finding the occurrences of “search_term” in the current file.

/search_term

46. esc

If you are in a different mode in Vim but you want to change to the command mode, the escape key is used for performing this task.

esc

47. v

Maybe you are in the command mode but you don’t know how to switch to the visual mode. You can simply use “v” to perform this task.

v

48. dgg

This command is used for deleting to the starting point of the file.

dgg

49. dG

Users should use this to delete to the end of the file.

dG

50. d$

d$-command will help to delete to the end of a line.

d$

Conclusion

The best you can get yourself used to the amazing Vim commands we have carefully described in this article is to try them out. These commands are essential for Vim users to know how to use them all.

olanrewajuo kunle

Graduate of Geology and Mineral Science. Technical Writer. Sports Writer. Graphics designer.

Published by
olanrewajuo kunle
Tags: Vim Commands

Recent Posts

Free Applications and Websites to Enhance Coding Skills

Obtaining any skill means that one will continuously upgrade it to become professional. It’s impossible…

3 weeks ago

How to Use Disk Drill Partition Recovery Software for Mac

With the keyboard shortcut "Command(⌘) + Option(⌥) + Delete(⌫)" you can completely remove a file…

3 weeks ago

21 React Project Ideas for Beginners

For some weeks now, you have been putting in a lot of effort in understanding…

4 weeks ago

Reasons for Creating a Custom Transportation Management Software

Transportation management software is used by organizations to administer, control, and manage the transportation aspect…

1 month ago

21 Angular project ideas for beginners

Angular project ideas have become so handy in bringing evolution and slight changes to many…

2 months ago

Tips for Optimal SaaS Platform Development

According to BetterCloud, approximately 80 percent of mobile applications will be running on mobile software…

2 months ago