Skip to content
TohDeKai edited this page Jan 11, 2022 · 2 revisions

These are my notes from the introductory video regarding Vim in Luminus Multimedia

What is VIM?

Vim is a modal text editor for Unix that comes with Linux, BSD, and macOS. It is known to be fast and powerful, partly because it is a small program that can run in a terminal (although it has a graphical interface). It is mainly because it can be managed entirely without menus or a mouse with a keyboard.

Opening file in Vim

In your terminal, enter: vim <file>. If no such file is found, a new file will be created that be saved later on.

To Open <files> in separate tabs, enter: vim -p <files>.

What is the buffer?

The buffer is the in-memory representation of the file. Any time you enter an existing file or create a new file using Vim, a buffer will be created to load the file from disk to memory. Any changes we make will be tracked in the buffer. When we are ready to update the file, the buffer can be written to disk.

VIM commands

Read more about the mods using :h vim-modes.

Normal/ Command mode

Press esc twice in other modes to return to normal mode.

Command Keys Remarks
Navigation around the buffer Arrow keys or HJKL -
Write buffer to file (save) :write or :w -
Exit Vim to terminal :quit or :q -
Write buffer to file and exit Vim to terminal :wq -
Write all buffers to respective files :wa -
Write all buffers to respective files and exit Vim to terminal :wqa -
Paste clipboard p -
Undo u -
Redo Ctrl + R -
Go to next word w Can indicate how many words you want to navigate through by indicating the number before the key
Go to previous word b Can indicate how many words you want to navigate through by indicating the number before the key
Go to the first line in file gg -
Go to the last line in file G note that it's case sensitive
Fix indentation in entire file gg = G Avoid doing this when indentation will change code behaviour like in Python
Move to line <n> :<n> -
Search for text that match <regex> :<regex> -
Jump to previous occurrence of <regex> N note that it's case sensitive
Jump to next occurrence of <regex> n note that it's case sensitive
Go to next tab gt Used when multiple tabs are opened in Vim
Go to previous tab gT Used when multiple tabs are opened in Vim
Split screen for buffer <file> horizontally :split <file -
Split screen for buffer <file> vertically :vsplit <file -
Navigate between split screens ctrl + w and then arrow keys -

Insert mode

This is where you will spend most of your time if you are writing code. Press i in normal mode to go into insert mode, at the bottom of the screen, you will see --INSERT-- when you are in insert mode. Press esc to exit insert mode.

Command mode

You can enter commands at the bottom of the window.

Visual mode

Can use to highlight texts. There are 3 modes: Visual, Visual Block, Visual Line. Similar to normal mode, but navigation extends a highlight. Press v in normal mode to go into visual mode, at the bottom of the screen, you will see --VISUAL-- when you are in visual mode.

Press shift + v in normal mode to go into visual-line mode, at the bottom of the screen, you will see --VISUAL LINE-- when you are in visual line mode. It allows you to navigate line by line.

Press ctrl + v in normal mode to go into visual-block mode, at the bottom of the screen, you will see --VISUAL BLOCK-- when you are in visual block mode. It allows you to navigate by a rectangular block.

Command Keys Remarks
Cut highlighted text d -
Copy highlighted text y -
Clone this wiki locally