VIM HotKeys

VIM is a powerful text editor widely used in programming and daily editing tasks. It supports multiple operating systems and is known for its efficient keyboard shortcuts. By mastering these shortcuts, users can significantly improve editing efficiency.

VIM Linux Shortcuts

Editing Functions

Shortcut Function Description
i Enter insert mode, insert text before the cursor
I Enter insert mode, insert text at the beginning of the current line
a Enter insert mode, insert text after the cursor
A Enter insert mode, insert text at the end of the current line
o Insert a new line below the current line and enter insert mode
O Insert a new line above the current line and enter insert mode
x Delete the character at the cursor's position
dd Delete the current line
yy Copy the current line
p Paste the copied or cut content
u Undo the last action
Ctrl + r Redo the last undone action

Navigation Functions

Shortcut Function Description
h Move the cursor one character left
j Move the cursor one line down
k Move the cursor one line up
l Move the cursor one character right
w Jump to the beginning of the next word
b Jump to the beginning of the previous word
0 Jump to the beginning of the current line
$ Jump to the end of the current line
G Jump to the last line of the file
gg Jump to the first line of the file
Ctrl + f Scroll down one page
Ctrl + b Scroll up one page

Search and Replace Functions

Shortcut Function Description
/ Start search and input the text to search
n Find the next match
N Find the previous match
:%s/old/new/g Replace all occurrences of "old" with "new" in the file
:s/old/new/g Replace all occurrences of "old" with "new" in the current line

File Operations

Shortcut Function Description
:w Save the file
:q Quit the VIM editor
:wq Save the file and quit the VIM editor
:x Save the file and quit the VIM editor (same as :wq)
:q! Quit without saving
:e filename Open the file "filename"
:saveas filename Save the current file as "filename"

Display and Window Operations

Shortcut Function Description
Ctrl + w + s Split the window and open a new window below
Ctrl + w + v Split the window and open a new window to the right
Ctrl + w + q Close the current window
Ctrl + w + h Switch to the left window
Ctrl + w + l Switch to the right window
Ctrl + w + k Switch to the upper window
Ctrl + w + j Switch to the lower window

About VIM

VIM is a full-featured text editor commonly used in programming, system administration, and everyday text editing tasks. Its name comes from "Vi IMproved," an improved version of Vi. VIM supports almost all operating systems and is the default editor in many Linux systems. The most distinctive feature of VIM is its keyboard shortcuts, allowing users to efficiently edit in different modes such as command mode, insert mode, and visual mode.

VIM offers powerful search and replace functions, supports regular expressions, and can be extended with plugins. It can handle nearly all text editing tasks and even replace more complex IDEs.

VIM Official Website Information

Common VIM Shortcut Questions

1. How to exit the VIM editor?

  • In command mode, type :q to exit. If the file is unsaved, use :q! to force exit. To save and exit, type :wq.

2. How to switch modes in VIM?

  • VIM has three main modes: command mode, insert mode, and visual mode. Press Esc to return to command mode; press i to enter insert mode; press v to enter visual mode.

3. Does VIM support multi-file editing?

  • Yes, VIM supports opening multiple files in different tabs or windows. You can open other files using the :e command or create a new tab with :tabnew.

4. How to perform batch replacement?

  • In command mode, use :%s/old/new/g to replace all occurrences of "old" with "new."

Conclusion

VIM is a powerful text editor with many shortcuts that help users improve efficiency. By mastering the common VIM shortcuts, users can be more proficient in editing code and documents. I hope the shortcut summary provided in this article will help you better understand and use the VIM editor, boosting your work efficiency. If you are a VIM beginner, start with these basic shortcuts and gradually master more advanced features.

5/5 - (1 vote)

Linux,Programming

Posted by HotKey Guru