- Move to the closest definition of the selected variable.
- Open the file path currently under the cursor. This will work with plugins
require('package')and other language-specific file paths.
- Centre the current line to the top of the screen.
- Centre the current line to the middle of the screen.
- Centre the current line to the bottom of the screen.
- Automatically indent the entire file.
- Word wrap the target line. Can be combined with movement operators like gqj, and visual selections like C-v + jjj + gq.
- Word wrap the previous paragraph.
- Word wrap the next paragraph.
- Copies the Nth line to below the position of the cursor.
- Copies the line the cursor is on to below the Nth line.
- Changes the content between the identifier N that the cursor is currently
on. E.g. ci" with the cursor on
helloand start Insert mode between the two
- Deletes the content between the identifier N that the cursor is currently
on. E.g. di" with the cursor on
- Yanks the content between the identifier N that the cursor is currently on.
E.g. yi" with the cursor on
"hello"will yank the text
- Deletes line N.
- Increments the number under the cursor.
- Decrements the number under the cursor.
- C-v + gC-a
- In a visual block selection, sequentially increment every number in the selection.
- Applies the specified
<command>against all lines matching with
Example: run a macro on all lines that match a search
Run the macro stored on
q on every line that contains
- Open one fold level under the cursor.
- Expand all folds under the cursor.
- Close one fold level under the cursor.
- Close all folds under the cursor.
- Toggle (open or close) the current fold under the cursor.
- Toggle (open or close) all folds in the file.
- Open one level of folds in the file.
- Expand all folds in the file.
- Close one level of folds in the file.
- Close all folds in the file.
- Yanks the selected text into register N.
- Pastes the text form register N.
Marks are a means of tracking important or frequently accessed lines of code. Both local and global marks can be set, offering the potential to make navigation across files substantially easier.
:help mark-motions for more information.
Creating global marks for files like
.vimrc might be useful.
- Set a local mark on the current line/column of the file under the guise 'a'.
- Set a global mark on the current line/column of the file under the guise 'A'.
- Jump to the beginning of the line for mark 'a'.
- Jump to the line and column for mark 'a'.
- Jump to the next mark.
- Jump to the previous mark.
- Jump to the next mark (at the beginning of the line).
- Jump to the previous mark (at the beginning of the line).
- List all current marks.
- :marks a
- Show the mark registered as 'a'.
- Delete all lowercase marks.
A buffer is an instance of a file loaded in Vim.
- List all buffers in the buffer list.
- Load buffer N in the current window.
- Reload the current buffer, discarding any changes.
- Open an empty buffer, splitting the window in the process.
- Open an empty buffer in the current window.
- :bufdo <command>
<command>across all buffers.
- Close all buffers.
A window is an area displaying the contents of a buffer.
- C-W + s
- Split the current buffer into two windows horizontally.
- C-W + v
- Split the current buffer into two windows vertically.
- C-W + T
- Move the current window into a new tab.
- C-W + =
- Make all windows in the current tab equally sized.
- C-W + o
- Makes the current window the only visible window.
- C-W + R
- Rotate all windows upwards.
- C-W + r
- Rotate all windows downwards.
- C-W + x + N
- Exchanges the current window with window N. Defaults to next window if window N is unspecified.
- :windo <command>
<command>across all windows.
A tab is a group of windows displaying buffers.
- Moves the current tab to the tab after tab N.
- Moves the current tab to the beginning of the tab list.
- Moves the current tab N positions to the right.
- Moves the current tab N positions to the left.
- :tabdo <command>
<command>across all tabs.
Vim remembers actions such as searching, substituting and marking in what it calls its "jump list". The Vim documentation has a list of commands considered "jumps". Jumps can be navigated between back and forth and span across files. Up to 100 jumps are stored.
+jumplist feature must be available in Vim to use this. See the
jumplist for more
:help jump-motions for more information.
- Display the jump list.
- Clear the jump list.
- Navigate to the next jump in the list.
- Navigate to the previous jump in the list.
Random and cool commands to speed up productivity.
- :so %
- Reload the
.vimrcfile if the current buffer is
- :so $MYVIMRC
- Reload the
.vimrcfile if current buffer is not
- :! <command>
<command>in the shell and return to Vim.
- :! git blame %:p
git blameon the current file in the current buffer.
%refers to the file in current buffer and
:pgrabs the full path of the file in the current buffer.
- Open a full screen, dedicated shell to run commands. Use
exitto return to Vim.
- Refresh the display in Vim; useful if the display in the terminal is accidentally cleared.
- Open a shell directly inside of Vim as a window, respecting all existing splits.
- :mksession <file>
- Create a Vim session file of all open buffers, including all windows and tabs.
- :tabdo windo N
- Run command N across all windows in all tabs.
Neat things to remember when opening files.
- vim $(<command>)
- Opens up the files that are output by
- vim -S <file>
- Restores a Vim session file.