Terminal-based text editor. A powerful text editor.
Why learn VIM? It’s an evergreen skill meaning if you learn once the skill lasts forever.
Why else learn VIM? Work faster and more efficiently without leaving the editor. Can do more from the keyboard. How much faster. Some folks say 300% faster.
From the web, “I do everything on vim: take notes, write user stories, my shopping list… I’m so used to it that sometimes I get myself pressing “esc” on other editors when I stop writing.”
Big debate here.
Nano is the easiest to learn. Similar to notepad on windows. Cut/paste shortcuts are also different from windows, same goes for VIM. Vim has more features than Nano. Vim is modal-based meaning it has modes so it has a steeper learning curve but once over this curve you will be faster.
WARNING: In Vim, and when using VIM VSCode extension, the typical windows cut, copy, and paste shortcuts of “Ctrl + X/C/V” no longer work. So learn these VIM commands quickly to avoid frustration. Also with VIM extension some VSCode shortcuts won’t work. For example, “ctrl + j” no longer opens the integrated terminal so use the “ctrl + backticks” shortcut.
Press “y” to copy, or “d” to cut the selection.
Move the cursor to the location where you want to paste the contents. Press “P” to paste the contents before the cursor, or “p” to paste it after the cursor. Can also use “+p”?
Note: The “y” to copy stands for “yank”
Cheat-sheet of commands here.
Type “vimtutor” into a Unix-based editor/command line and and you can go through a 30-minute tutorial/overview.
Note: Case matters in VIM. Using “P” versus “p” will paste contents in a before or after the cursor respectively. Enter insert mode with “I” versus “i” will start you off in a slightly different place.
Like macros for terminal commands
“:q” – quit VIM from normal mode
“:q!” – quit without saving changes from normal mode
“:wq” to save
“:wq” to save and quit from normal mode
“i” for insert mode OR “ESC” for normal mode
Open up a file in VIM editor with “vim hello.js” command from terminal.
When you open the Vim editor you will start in “normal mode” but you can toggle between “insert, command and visual modes” with “i”, “:”, and “v” respectively. Press “ESC” to get back to normal mode.
“hjkl” move around like arrow keys
“x” to delete character.
“dd” to delete entire line
“u” to undo
“:whatevsNumber”
“+p” to paste from system clipboard
“:!” to run command (awesome) so for example “:!node hello.js”
Really four ways to enter insert mode with “iIaA”
i – insert mode to the left of the highlighted character
I – insert mode at the beginning of the current line
a – insert mode to the right of the highlighted character
A – Enter insert mode at the end of the line. Appending to the end of the line.
“xr” – making changes while in command mode
“x” is like delete out a character
“r” is for replacing characters under the cursor with the new cursor you type in.
Don’t need to ditch VSCode to get the benefits of VIM.
1.) Inside “VSCode” search for VIM extension “vscodevim.vim” with ~2.2m downloads.
2.) Set up key repeating by running command from installation docs in the terminal, (not needed for windows). If you press “i” to enter insert mode and then the enter key a bunch to create lines. Then hit “ESC” and then press and hold “k” to go up. If this works you are good to go.
Optional: A lot of people re-map caps lock to be the escape key so its closer.
VIM Basics in 8 Minutes here
Fireship Video here.
Ben Awad Video here