List of content you will read in this article:
Vim is the most recent version of Vi Editor that supports text and graphical interfaces; also runs on any platform. The problem with learning Vim is, You should keep practicing and working on it.
This guide will help you increase your productivity and chances of learning VIM by working with VIM Shortcuts. Let’s quickly move to the website and learn more about it.
What Is Vim Editor? [Definition]
Vim stands for "Vi IMproved." It is a Unix text editor with Linux, BSD, and macOS. It's known for being quick and powerful, thanks to its simple application that can operate in a terminal (although it has a graphical interface).
It's mainly because it can be operated totally without the use of menus or a mouse. However, Vim is not how current computer users expect to edit text. Yet it's how Unix administrators worldwide update config files, changelogs, scripts, and more.
Features of Vim
- It has a small memory footprint.
- It's a command-based system. With just a few commands, you can complete difficult text-related activities.
- It is very configurable and stores its settings in a simple text file.
- There are numerous Vim plug-ins available. These plug-ins can greatly increase the usefulness of the program.
- Multiple windows are supported. This function allows you to split your screen into numerous windows.
- It has many tabs that allow you to work on multiple files simultaneously.
- It has recording tools that allow you to record and play Vim commands repeatedly.
How to use Vim Editor?
Because Vim's developers know how straightforward it is, they built vimtutor, a short, interactive explanation of the essentials. Although Vim has a lot of power, there are just a few controls you need to master to utilize it effectively.
- Start Vim by entering Vim in a terminal or running gvim on your desktop.
- To enter input text mode, press I. You can only type text into your document while in insert mode. In insert mode, there are no commands.
- Enter normal mode by pressing Esc, which is used for commands.
- You can move your cursor with h (left), j (down), k (up), and l (left) in regular mode (right). It could be easier to remember that j is down if you visualize it as a Down arrow.
- To exit Vim, type :wq to save your work :q! to discard any changes that haven't been saved.
Other than these fundamentals, all other Vim commands are arguably for convenience and efficiency.
Vim Shortcuts List/VIM Hotkey List
Cursor Movements
- h - moving the cursor to the left
- j - moving the cursor down
- k - moving the cursor up
- l - moving the cursor to the right right
- H - Jumping directly on the top of the screen
- M - Jumping in the middle of the screen
- L - Jumping directly to the bottom of the screen
- w - Jumping on the start of a written word
- e - Jumping toward the end of a written word
- Ctrl + e - Moving the screen down by one line without the use of a cursor
- Ctrl + y - Moving the screen up by one line without making use of the cursor
- Ctrl + b - Moving one fullscreen forward
- Ctrl + f - Moving one fullscreen backward
- Ctrl + d - Moving ½ fullscreen forward
- Ctrl + u - Moving ½ fullscreen backward
Insert mode - inserting/appending text
- i - Inserting before the cursor
- I - inserting at the beginning of a line
- a - inserting after the cursor
- A - inserting at the end of the line
- o - Opening new lines below the selected line
- O - Opening new lines above the selected line
- ea - inserting at the end of the selected word
- Ctrl + h - deleting characters before the cursor
- Ctrl + w - deleting words before the cursor
- Ctrl + j - Creating a new line while inserting a new mode
- Ctrl + t - Moving right with one line shift width
- Ctrl + d - Moving left with one line shift width
- Ctrl + ox - Quickly access normal mode for executing any normal mode command
- Esc - Exiting the insert mode
Working with multiple files
- :e[dit] file - Editing files in new buffer
- :bn[ext] - Jumping to the next buffer
- :bp[revious] - Jumping back to the previous buffer
- :bd[elete] - Deleting a buffer
- :b[uffer]# - Hoping directly to a buffer through the index
- :b[uffer] file - Hopping to a buffer through the file
- Ctrl + ws - Splitting the Window
- Ctrl + wv - Vertical splitting of the Window
- Ctrl + ww - Switching between the windows
- Ctrl + wq - Quitting Window
- Ctrl + wx - Exchanging the current Window with the next Window
- Ctrl + w= - Adjusting the height and width of all the Windows as the same
- Ctrl + wh - Jumping the cursor to the next Window
- Ctrl + wl - Jumping the cursor to the next Window
- Ctrl + wj - Jumping the cursor to the Window present below
- Ctrl + wk - Jumping the cursor to the Window present above
- Ctrl + wH - Making selected Window expand to the full screen
- Ctrl + wJ - Making selected Window expand to the full screen at the right bottom
Cut and paste
- yy - (Copy command) pull a single line
- 2yy - (Copy command) pull two lines
- yw - (Copy command) pull the characters of the words below the cursor to start the next position
- yiw - (Copy command) Pull the words below the cursor
- yaw - (Copy command) Pull the words selected with the cursor and add space
- p - (paste command) paste from clipboard after the cursor position
- P - (paste command) paste from the clipboard before the cursor position
- gP - (paste command) paste content before cursor and leave cursor after newly added text
- dd - (cut command) deleting a line
- 2dd - (cut command) deleting two lines
- dw - (cut command) deleting the characters of the word selected from the cursor
- diw - (cut command) deleting words selected through the cursor
- D - (cut command) deleting text at the end of the selected line
- x - (cut command) deleting characters
Editing
- r - replacing only one character
- R - replacing more a single characters
- J - Joining below the line with the current one, along with adding one-line space between them
- gJ - Joining below the line with the current one without adding any space
- cc - Changing the entire line
- C - Changing at the end of a line
- ciw - Replacing an entire word
- cw or ce - Replacing at the end of a word
- s - deleting characters along with substituting its text
- S - Deleting lines along with substituting their text
- xp - Trasposing 2 letters
- u - Undo
Search and replace
- /pattern - Quickly search patterns
- ?pattern - Quickly search backward for a pattern
- n - Repeating search in a similar direction
- N - Repeating searches in different directions
- :%s/old/new/g - Replacing old contents with the new ones all over the file
- :noh[lsearch] - Removing highlights from search matches
If you want to know more about the VIM search command, check out this post,
Tabs
- :tabnew or :tabnew {page.words.file} - Opening a new file in a new tab
- Ctrl + wT - Moving the current split Window into an old tab
- gt or :tabn[ext] - Moving to a next tab
- gT or :tabp[revious] - Moving back to the previous tab
- :tabm[ove] # - Moving selected tab to a pointed location
- :tabc[lose] - Closing the current tab
- :tabo[nly] - Closing every tab except the selected one
Summing up
You can write code at incredible speed with the VIM editor. Just get begun, and the rest will take care of itself. Use a vim plug-in for your text editor if you wish to integrate into the vim universe gradually. A vim plug-in is available for all popular text editors (here's one for VsCode). So there you have it, the best of all worlds! When you're sure you're ready, make the complete transition.
This is all about VIM shortcuts command in Linux that will improve your performance.
People also read:
I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.