I’ve just installed Vim on Windows 10. I’m completely new to Vim so if you have any great resources for learning, please leave a comment!
Vim is a text editor for your Command Prompt (or Terminal).
To install Vim on your Windows machine, you will have to download the executable file here.
To start up Vim, you can open your Command Prompt and type
- Switch between command mode and insert mode.
- To switch from command mode to insert mode and insert text at the current cursor position, press
- To switch from command mode to insert mode and insert text at the beginning of the line, press
- To switch from command mode to insert mode and insert text at the end of the line, press
- To switch from insert mode back to command mode use
- Opening new lines
- To open a new line after the current one and begin inserting text (switching to insert mode) use
- To open a new line before the current one and begin inserting text (switching to insert mode) use
- Navigating in the source using
- Navigate up a line, press
- Navigate down a line, press
- Navigate left a character, press
- Navigate right a character, press
- To save current edits use
:w (short for write).
- To exit, type
:q (short for quit).
- To save and exit, type
- To force exit without saving, type
- To force save and exit, type
- Copy and paste
- To select a block of a text,
Ctrl + v to switch to the visual mode, then select a block using the directional keys (
- To copy the selected block,
yy (yank line).
- To paste the selected block,
- To paste before cursor,
- Tab complete
- To use tab completion,
CTRL + p.
- Move to beginning and end of a file
- To move to the beginning of the line,
- To move to the end of the line,
- To substitute the character under the cursor, type
r followed by the character you will substitute.
- To switch to replace mode use
Shift + r and start typing.
- Combine operators (like delete) with motions (like end of word)
- As mentioned, Vim commands are composable. So you can combine operations like delete/change/copy with motions like beginning/end of word/line.
- To delete to the end of the word, type
- To delete to the end of the line, type
- To delete the text within quotes, double quotes, parentheses, brackets use
- To copy to the end of the word, type
- You can type a number before the command to execute it multiple times
- To delete 4 lines, type
- Repeat last command by typing
- Jump to specific position in a file.
- To jump to the beginning of a file use
- To jump to the end of a file use
- To jump to the specific line in a file use
8gg (8 is the line number).
- Search forward and backward.
- Match parentheses and brackets.
- To match the current parentheses or bracket use
- Split horizontally and vertically.
- To split the screen horizontally use
- To split the screen vertically use
- Switch between splits.
- To switch to the next split screen use
CTRL + ww.
- Jump forward and backward.
- To jump forward a page use
CTRL + f.
- To jump backward a page use
CTRL + b.
- Modify your environment via dotfiles.
- You can do that after reading this tutorial 🙂 An easy way to edit your
.vimrc file is
- Execute a shell command.
- To execute a shell command simply type
:sh followed by the command.
Here is a cheat sheet for all commands:
This getting started guide by SitePoint provided the above information and goes more in-depth.