- Comes preinstalled on many many Unix-like machines
- Support for a large and fanatic community
- Concepts are portable to many full featured IDEs Jet-Brains, VS-Code
- Vim shortcuts are often avaialble in other unix programs
- You never stop learning vim
Interactive tutorial for basic movement
vimtutor
- openvim
- Type
:help
in your vim
There are 3 main modes for vim:
- Normal mode: Where you move around and do most of the things
- Insert mode: Where you insert text in short bursts
- Visual mode: For text selection, copy paste, etc
-
esc
: exit back to normal mode -
i
enter insert mode -
v
enter visual mode
You should always be in visual mode, unless you are inserting text. The power of vim is treating text as repeatable actions. -
/
: Search mode, jump back and forth withn
andN
-
hjkl
for moving around -
Ctrl+o
Jump to the last palce you have viewed -
Ctrl+i/Tab
Jump forward -
w,b
to skip words forward and back -
Ctrl+d
page down -
Ctrl+u
page up
c
changed
deleter
replacey
yankp
pasteu
undoCtrl+r
redo.
repeat the last editing action
You can combine operator
+ number
+ motion
Examples:
- Delete 7 lines down
- Change word
- Change between parenthesis
:w
write:q
quit:wa
write all:wq
write and quit TIP: Remap the following to save frustration:
command! Q q
command! W w
command! Wq wq
command! WQ wq
command! WA wa
command! Wa wa
command! Qa qa
command! QA qa
>
indent selected line or text right<
indent selected or text left=
Align indentation*
Search word under cursor forward#
Search word under cursor back
Vim has an extensive plugin system. You can find a plugin for syntax highlight, spell check, linting, code completion, git integration.
To use plugins you need a plugin manager. There are a few to choose from.
After following installation process, simply clone the relevant repository into $HOME/.vim/bundle
(other actions may apply)
-
Basically anything by Tim Pope
- Plugin manager: vim-pathogen
- Sensible settings: vim-sensible
- Git integration: vim-fugitive
-
vim-airline: Compact status line with lots of useful information
-
Code completion:
-
Linting:
brew install vim
Then run vim --version
to make sure you see
+lua, +python
Main configuration file is $HOME/.vimrc
Additional configurations an plugins $HOME/.vim
Clone this repository as .vim
git clone https://github.com/amanusk/dotvim.git .vim
ln -s .vim/vimrc .vimrc
cd .vim &&
git submodule init &&
git submodule update
git submodule foreach git pull origin master
git submodule add http://github.com/tpope/vim-fugitive.git bundle/fugitive
Delete the relevant section from the .gitmodules file.
Stage the .gitmodules changes git add .gitmodules
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule (no trailing slash).
Run rm -rf .git/modules/path_to_submodule
Commit git commit -m "Removed submodule <name>"
Delete the now untracked submodule files
rm -rf path_to_submodule
ln -s .vim/.bash_aliases .bash_aliases &&
ln -s .vim/tmux.conf .tmux.conf
- Vim-casts: Many useful vim features, novice and advanced
- Setting up vim for typescript https://www.vimfromscratch.com/articles/setting-up-vim-for-typescript/