-
Notifications
You must be signed in to change notification settings - Fork 4
More about VIM
These are my notes from the introductory video regarding Vim in Luminus Multimedia
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.
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>
.
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.
Read more about the mods using :h vim-modes
.
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 | - |
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.
You can enter commands at the bottom of the window.
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 | - |
Peer Learning
Guides
Setting Up Checkstyle
Setting Up Java
Setting Up MacVim
Setting Up Stu
Setting Up Unix For Mac
Setting Up Unix For Windows
Setting Up Vim
Setting up SSH Config
SSH Without Password
Copying Files From PE Nodes
Using tmux
CS2030 Contents
Lecture 1 SummaryLecture 2 Summary
Access Modifiers
Lecture 3 Summary (Polymorphism)
Compile Time Type VS Runtime Type
Abstraction, Encapsulation, Inheritance, and Polymorphism
SOLID Principles
Class VS Abstract Class VS Interface
Comparable VS Comparator
Generic Types T
HashMap
Raw Types with Generic
Lambda expression
PECS (Producer Extends Consumer Super)
Optional
Streams
Parallel Streams
Monad
Functors and Monads with Category Theory