The goal - 20% of the features covers the 80% daily usage
Why you shoud learn Vim?
- Basically it's everywhere, only if you're using Unix/Linux/macOS.
- Edit your confuguration on the servers.
- Some magic, so many text editors were dead in the history, but it isn't.
- High efficiency
- No mouse or trackpad needed.
- Running fast, but less resource is required.
- Coding faster, less unnecessary finger movement.
How to learn
- Why it's so hard to learn
- Because of it isn't like the normal text editor, it has differnet mode.
- Everyone has their own setup, but it makes it hard to know why they set it up like that.
- Focus on what you need only
Show my own setup
Basic
- Installation, macOS
- New file, edit, save
- Movement
- Copy & paste
Plugins
- vimrc
- vim-plug
- Key bindings
- Cases study
- Open folder
- Open file manager, adding files, deleting files, opening files
- Switch, close tabs
- Jump
- Block selection
- Unit test
- Terminal
- Git pull, git commit, git push
Next
-
Use it, VSCode + Vim
-
vimtutor
-
Useful links
- different mode, normal mode, visual mode, insert mode, command mode,
:h vim-modes
for more detail - :q, :q! :wq, :w
<file path>
-
movement
- hjkl
- gg, G
- 0, ^, $
- f, F
*
/<regex>
/\v<regex>
:<number>
-
selection
- v,
<ctrl>v
,V
- w, W
%
vi(
,viw
,vi"
,vi'
v%
- v,
-
selection + paste
- yyp
-
others
- u, U
- J
-
set nu
-
practice
- search for a setting
- copy & paste
- comment out for a setting
- basic setting
- builtin func all in lowercase, user-defined function must be capital letter
- :h is our friend
Plugins manager - https://github.com/junegunn/vim-plug
" lsp support
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'ajh17/VimCompletesMe'
" language specific
Plug 'fatih/vim-go', { 'tag': '*' }
Plug 'rust-lang/rust.vim'
Plug 'leafgarland/typescript-vim'
" utils
Plug 'prabirshrestha/asyncomplete-file.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'preservim/nerdtree'
Plug 'itchyny/lightline.vim'
Plug 'mhinz/vim-startify'
Plug 'jiangmiao/auto-pairs'
Plug 'valloric/MatchTagAlways'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'ap/vim-buftabline'
Plug 'qpkorr/vim-bufkill'
Plug 'easymotion/vim-easymotion'
Plug 'tpope/vim-surround'
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
" color theme
Plug 'romainl/flattened'
" unit test
Plug 'janko/vim-test'
Plug 'tpope/vim-dispatch'
-
practice
- Open from a folder -
vim .
ormvim .
or with alfred <leader>wh
- file creation, rename, update
- search files by filename, FZF
- search files' content by keywords, Find
- show currentn active buffer's path in the menu,
<leader>ff
- easymotion,
<leader><leader>s
- switch window,
<ctrl>n
,<ctrl>p
- jump between buffers
<ctrl>w+hjkl
- delete
<leader>bw
,<ctrl>wq
- code folding, setting, zf, zo, zc
- copy & paste
- replace ' to "
- with surround
- for the whole file
:%s
- for the selection only
- change letter's case, uppercase, lowercase (constant)
- format with ==,
<leader>fmt
- comment, gc, gcc
- run unit test
- Open from a folder -
-
set it up from very beginning
- basic setting
- https://github.com/macvim-dev/macvim
- https://github.com/junegunn/vim-plug
- plugins & their setting, key bindings
- vim-easymotion
- vim-surround
- try
vimtutor
first (no more than 30mins) - read https://learnvimscriptthehardway.stevelosh.com (no more than two days)