Here we can see, “Cheat Sheet: The Vim Linux Command Line Editor Cheat Sheet”
Keep this Vim cheat sheet handy to find out or relearn useful Vim commands.
Powerful, efficient, and highly configurable— that’s Vim in a nutshell for you. This cross-platform instruction text editor has been around for ages and features a solid online community you’ll look to for help. The simplest part is that Vim is free and open source.
If you’ve only dabbled in Vim so far, the subsequent step is getting comfortable with Vim commands, i.e., Vim’s keyboard shortcuts. (This is important as long as Vim may be a keyboard-centric text editor.)
We’ve even compiled the simplest Vim shortcuts into a cheat sheet for you! Scroll right down to discover it. You’ll also download a PDF version of this Vim cheat sheet and reserve it to your desktop for quick access.
Remember that Vim (Vi Improved) may be modified like the Unix-based text editor Vi, which ships with several Linux distros. So you’ll find that several Vim also commands functions as Vi commands.
The Vim Commands Cheat Sheet
Shortcut | Action |
---|---|
Cursor Movement | |
h | Move cursor left |
j | Move cursor down |
k | Move cursor up |
l | Move cursor right |
w OR ¹W | Move cursor to the start of the next word |
b OR ¹B | Move cursor to the start of the previous word |
e OR ¹E | Move forward to the end of a word |
0 | Move to the start of the line |
^ | Move to the first non-blank character of the line |
$ | Move to the end of the line |
G | Go to the last line of the document |
nG OR :n | Go to line number n |
‘ | To the position before the latest jump, / where the last “m'” / “m`” command was given. |
fx | Move to next occurrence of character x |
tx | Move to one character before the character x |
} | Move to next paragraph |
{ | Move to previous paragraph |
H | Move to home (top) of screen |
L | Move to last line of screen |
M | Move to middle of screen |
3, f, x | Move to 3rd instance of character x forward from cursor on current line. |
3, F, x | Move to 3rd instance of character x back from cursor on current line. |
Editing a File | |
r | Replace a single character |
dd | Cut (delete) a line |
yy | Yank (copy) a line |
2yy | Yank (copy) two lines |
J | Join line below to the current one |
cc OR S | Change (replace) entire line |
cw | Change (replace) to the end of the word |
c$ | Change (replace) to the end of the line |
s | Delete character and substitute text |
xp | Transpose two letters (delete and paste) |
u | Undo |
Ctrl r | Redo |
. | Repeat last command |
Search and Replace | |
* | Search for word under cursor |
/pattern | Search for pattern |
?pattern | Search backward for pattern |
n | Repeat search in same direction |
N | Repeat search in opposite direction |
:%s/old/new/g | Replace all instances of old with new |
:%s/old/new/gc | Replace all instances of old with new, with confirmations |
Screen Movement | |
Ctrl u | Move screen up by half page |
Ctrl b | Move screen up by one page |
Ctrl d | Move screen down by half page |
Ctrl f | Move screen down by one page |
zz | Center screen on cursor |
zt | Align top of screen with cursor |
zb | Align bottom of screen with cursor |
Insert Mode (Insert Text) | |
i | Enter insert mode |
I | Insert at the beginning of the line |
a | Insert (append) after the cursor |
A | Insert (append) at the end of the line |
o | Append (open) a new line below the current line |
O | Append (open) a new line above the current line |
ea | Insert (append) at the end of the word |
Esc | Exit insert mode |
Change Case | |
~ | Toggle case (Case => cASE) |
gU | Uppercase |
gu | Lowercase |
gUU | Uppercase current line (also gUgU) |
guu | Lowercase current line (also gugu) |
Visual Mode (Mark Text) | |
v | Start visual mode, mark lines, then do a command (like y-yank) |
V | Start linewise visual mode |
vo | Move to other end of marked area |
Ctrl v | Start visual block mode |
vO | Move to other corner of block |
vaw | Mark a word |
vab | Mark a block with () |
vaB | Mark a block with {} |
vib | Mark inner block with () |
viB | Mark inner block with {} |
Esc | Exit visual mode |
Visual Commands | |
> | Shift text right |
< | Shift text left |
#ERROR! | Auto-indent current line |
<< | Shift current line left by shiftwidth |
>> | Shift current line right by shiftwidth |
y | Yank (copy) marked text |
d | Delete marked text |
~ | Switch case |
Folding Commands | |
zf#j | Create a fold from the cursor down # lines |
zf/ | String creates a fold from the cursor to string |
zj | Move the cursor to the next fold |
zk | Move the cursor to the previous fold |
za | Toggle a fold under cursor |
zo | Open a fold at the cursor |
zO | Open all folds at the cursor |
zc | Close a fold under cursor |
zm | Increase the foldlevel by one |
zM | Close all open folds |
zr | Decrease the foldlevel by one |
zR | Decrease the foldlevel to zero—all folds will be open |
zd | Delete the fold at the cursor |
zE | Delete all folds |
[z | Move to start of open fold |
]z | Move to end of open fold |
Tabs | |
#gt | Move to tab number # |
Ctrl w, t | Move the current split window into its own tab |
:tabmove # | Move current tab to the #th position (indexed from 0) |
:tabnew filename/ :tabn filename | Open a file in a new tab |
:tabclose / :tabc | Close the current tab and all its windows |
:tabonly / :tabo | Close all tabs except the current one |
gt / :tabnext / :tabn | Move to the next tab |
gT / :tabprev / :tabp | Move to the previous tab |
Working With Multiple Files | |
:e filename | Edit a file in a new buffer |
:ene | Open a blank file for editing |
:bnext / :bn | Go to the next buffer |
:bprev / :bp | Go to the previous buffer |
:bd | Delete a buffer (close a file) |
:sp filename | Open a file in a new buffer and split window |
:vs filename | Open a file in a new buffer and vertically split window |
Ctrl w, s | Split window |
Ctrl w, w | Switch windows |
Ctrl w, q | Quit a window |
Ctrl w, v | Split window vertically |
Ctrl w, h | Move cursor to window left |
Ctrl w, l | Move cursor to window right |
Ctrl w, k | Move cursor to window above |
Ctrl w, j | Move cursor to window below |
Ctrl w, r | Rotate windows clockwise |
Ctrl w, T | Move current window to a new tab |
:on | Close all windows except current window |
Ctrl w, | | Maximize width of active window |
Ctrl w, 1, | | Minimize width of active window |
Ctrl w, _ | Maximize height of active window |
Ctrl w, 1, _ | Minimize height of active window |
Ctrl w, = | Equalize the size of windows |
Exiting a File | |
:w | Write (save) the file, but don’t exit |
:wq | Write (save) and quit |
😡 OR ZZ | Write (save) current file if modified and quit |
:q | Quit (fails if there are unsaved changes) |
:q! | Quit and discard unsaved changes |
:qa | Quit all buffers and windows |
ZQ | Quit without checking for changes |
¹Word can contain punctuation. |
Vim Improved
Vim is undoubtedly an excellent text editor, but it could do with a couple of useful features that most modern text editors are equipped with. The great news is that you can add top features from other text editors to Vim!
Conclusion
I hope you found this guide useful. If you’ve got any questions or comments, don’t hesitate to use the shape below.
User Questions:
- Is Vim an instruction editor?
Vi and Vim. Vi may be a very powerful command-line text editor. It’s used for everything from quick fixes in configuration files to professional programming and even for writing large, complex documents like this book. … On many modern systems, Vim is installed because of the default version of Vi.
- What is vim editor in Linux?
Vim is a complicated and highly configurable text editor built to enable efficient text editing. Vim text editor is developed by Bram Moolenaar. It supports most file types, and the vim editor is additionally referred to as a programmer’s editor. We will use its plugin supported our needs.
- Can you edit in Vim?
Edit the file with Vim: Open the enter vim with the command “vim.” Type “/” then the name of the worth you’d wish to edit and press Enter to look for the worth within the file. … Press ESC then type “:wq!” then press Enter to save lots of the changes and exit vim.
- Vim cheat sheet
- Vi/Vim Graphical Cheat Sheet