This is the seventh day of my participation in the August More text Challenge. For details, see:August is more challenging

DeliberatePracticeVimIn30Days

What does 30 days of deliberate practice achieve, muggles or gods?

I use Vim programming way to develop have 3 years of experience, but despite three years of experience, but is only used to the quick edit mode, which are frequently used Vim although just know the tip of the iceberg, but I have in the development efficiency had the very big enhancement, because I work in the Android, and front-end development, Although I use the IDE, but it does not affect me to use Vim plug-in to develop, so in order to better play Vim programming advantages, and improve their coding efficiency, so there is this warehouse.

I like and admire Bisqwit code typing very much, the code can output quickly on the screen, the key points are like flying, and I also like the way GeoHotz uses Vim to type code, so I secretly encourage myself to be like them, I may not be as good as them, but this does not affect me to be closer to them.

The name of the resource Introduction to the
Seven efficient text editing habits By Bram Moolenaar (Vim)
Vim Practice (2nd edition) Easily Vim’s Best book
Vim User Manual Chinese version 72 Vim User manual
Modern. Vim. 2018.5 Modern Vim

The Vim project I used for the first time was spf13-Vim. When I searched Github, it was one of the most popular projects on Star. There is a project called SpaceVim in China, and the author is also a good person. Because the project integrates a lot of plug-ins, in my impression, there are 70 or 80 spf13 plug-ins alone, which do not count when started, but many plug-ins are unused by themselves, and they do not pay much attention to.

My recommendation for Vim is to try using someone else’s Vim DotFiles first, because their configuration is so much better than your whiteboard. Vim is great because it has a lot of add-ons, and it’s like transformers. But if you don’t install anything, you’re really not as fast with Vim as you would with an IDE. Try to use other people’s projects first, get familiar with Vim operation first, and then customize your own Vim according to your own needs, and install the plug-ins you need.

Commonly used Vim plug-in recommendation, more plug-ins deliberately view Vimawesome

The name of the resource Introduction to the
fugitive-vim fugitive.vim: A Git wrapper so awesome, it should be illegal
surround-vim surround.vim: quoting/parenthesizing made simple
nerdtree A tree explorer plugin for vim
vim-airline lean & mean status/tabline for vim that’s light as air
. vimawesome

About my previous record of tossing Vim

Vim toss posts

Day01

Download and install NeoVim

NeoVim website

  • Download nvim-macos.tar.gz
  • Extract: tar xzvf nvim-macos.tar.gz
  • Run ./nvim-osx64/bin/nvim

Since there is no desktop shortcut, I mapped it to the.zshrc file

# NeoVim
alias nvim='./nvim-osx64/bin/nvim'
Copy the code

Every time I just type nvim into the terminal, NeoVim is deliberately opened quickly

The difference with Vim

~/.vimrc corresponds to $CONFIG_HOME/nvim/init.vim ~/.vim corresponds to $CONFIG_HOME/nvimCopy the code

Neovim can use vim’s configuration file. If you have vim’s configuration, you can use a direct soft link:

$(~) ln -s ~/.vim .config/nvim
$(~) ln -s ~/.vimrc .config/nvim/init.vim

Copy the code

To use a separate configuration for nvim, create a configuration file under.config:

$(~) mkdir .config/nvim
$(~) touch .config/nvim/init.vim
Copy the code

The previous spF-13 project used Vundle to install plug-ins. In order to experience other ways, here we change to VimPlug to install plug-ins. On the first day, install some commonly used plug-ins:

- Finishing ... Done! │~ -fzf: Already installed │~ -ctrlp. vim: Already installed │~ -vim-airline: Already installed │~ -tagbar: Already installed │~ -nerdtree: Already installed │~ -fzf. vim: Already installed │~ -nerdtree: Already installed │~ -fzf. vim: Already installed Already installed │~ - Gruvbox: Already installed - vim-easymotion: Already installedCopy the code

Day2

Customize some common shortcut keys

Customizing some common shortcut keys, but encountered the problem that the keys did not work. I searched a lot of information but failed to find the reason. Finally, I found that it was caused by my own improper operation

It is found that the nvim set meta key in iterm2 does not work. This is a problem that exists all the time. Check the data to see if there is a better solution

Set left Option to Esc+ in iterm

Silent indicates that no echo is displayed

Also learned the use of some simple Vim function scripts

Such as:

function! DateAndTime() redraw echohl WarningMsg echo strftime(" ⏰ current time %Y-%m-%d %H:% m :%S ⏰ ") echohl NONE endfunction "Enter xtime Iab xtime <c-r>=strftime("%Y-%m-%d %H:% m :%S")<cr> nnoremap < m-t > :call DateAndTime()<CRCopy the code

You can simply and quickly output the current time

The init.vim file for the next day is as follows

Set relativenumber :let mapleader = "," :let g:mapleader = "," call plug#begin('~/.vim/plugged') "vim-airline Plug 'vim-airline/vim-airline' " colorscheme gruvbox Plug 'morhetz/gruvbox' " nerdtree Plug 'preservim/nerdtree' " Tagbar Plug 'majutsushi/tagbar' " ctrlp Plug 'ctrlpvim/ctrlp.vim' " MarkdownPreview Plug 'suan/vim-instant-markdown', {'for': 'markdown'} " Fzf Vim Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' set rtp+=/usr/local/opt/fzf Plug '/usr/local/opt/fzf' " easymotion Plug 'easymotion/vim-easymotion' " wakatime Plug 'wakatime/vim-wakatime' call plug#end() exec 'cd ' . Fnameescape ('/Users/itgoyo/Documents/Vim) "use CTRL + HJKL switch window" nnoremap < C - l > > < C - w l didn't effect the usage because has been blocked by direction of shortcuts :noremap <leader>h < c-w >h :noremap <leader>j < c-w >j :noremap <leader>k < c-w >k :noremap <leader>l < c-w >l  inoremap <leader>w <Esc>:w<cr> noremap <leader>w :w<cr> "noremap <D-S> :w<cr> "noremap <leader>s :w<cr> ":noremap <leader>s :w<cr> :noremap <leader>p :MarkdownPreview<cr> "stackoverflow <silent> < c-s > :update<CR> vnoremap <silent> <C-S> <C-C>:update<CR> inoremap <silent> <C-S> <C-O>:update<CR> Set timeoutlen=1 ttimeoutlen=0 "install easymotion" Plugin 'easyMotion/vim-easyMotion' "Mode Settings let &t_SI.="\e[5 q" "SI = INSERT mode let &t_SR.="\e[4 q" "SR = REPLACE mode let &t_EI.="\e[1 q" "EI = NORMAL mode (ELSE) "Cursor settings: " 1 -> blinking block " 2 -> solid block " 3 -> blinking underscore " 4 -> solid underscore " 5 -> blinking vertical bar  " 6 -> solid vertical bar "let &t_SI = "<Esc>]50;CursorShape=1\x7" "let &t_SR = "<Esc>]50;CursorShape=2\x7" "let &t_EI = "<Esc>]50; CursorShape=0\x7" "MarkdownPreview "let g:instant_markdown_port = 8888 *.go,*.sh,*.php,*.java,*.py,*.md,*.txt,*.html write " colorscheme set bg=dark colorscheme gruvbox " NERDTree map <C-e> :NERDTreeToggle<CR> " Tagbar nmap <C-t> :TagbarToggle<CR> " Tagbar nmap <silent> <leader>tb :TagbarToggle<cr> " fzf " Always enable preview window on the right with 60% width let g:fzf_preview_window = 'right:60%' nmap <C-z> :Files<CR> nmap <C-u> :Buffers<CR> " <Leader>f{char} to move to {char} nmap <Leader>f <Plug>(easymotion-overwin-f) " s{char}{char} To move to {char}{char} nmap s <Plug>(easyMotion -overwin-f) "nmap <Leader>w <Plug>(easymotion-overwin-w) "switch buffer" Buffer Navigation nmap <C-[> :bprevious<CR> nmap <C-]> :bnext<CR> nmap <M-[> :bprevious<CR> nmap <M-]> :bnext<CR> Nnoremap <Tab> :bnext<CR> nnoremap < s-tab > :bprevious<CR> Let $FZF_DEFAULT_OPTS = '--layout=reverse' "open FZF in floating window let g:fzf_layout = {'window': 'call OpenFloatingWin()' } function! OpenFloatingWin() let height = &lines - 3 let width = float2nr(&columns - (&columns * 2 / 10)) let col = Float2nr ((&columns - width) / 2) "Float2NR ((&columns - width) / 2)" Let opts = {\ 'relative': 'editor', \ 'row': height * 0.3, \ 'col': col + 30, \ 'width': width * 2 / 3, \ 'height': height / 2 \ } let buf = nvim_create_buf(v:false, v:true) let win = nvim_open_win(buf, v:true, Opts) "Set float window to highlight Call Setwinvar (win, '& Winhl ', 'Normal:Pmenu') setlocal \ buftype=nofile \ nobuflisted \ bufhidden=hide \ nonumber \ norelativenumber \ signcolumn=no Endfunction set modifunction on "Keymap "<k0> - <k9> keypad 0 to 9 "<S-... "< C > Shift + key -... Key "< > Control + M -... "> <A-... > with < M -... > "<Esc> Escape key <Up> Cursor move key <Space> Insert Space <Tab> Insert Tab <CR> = <Enter> <D> Command "quick switch nmap J <C-w> J nmap H < c-w >h nmap K < c-w > K nmap L < c-w > L nmap w < c-w >w "<Esc>O inoremap [[<CR>]<Esc>O inoremap { {< CR >} < Esc > O "time display function! http://vim.wikia.com/wiki/Insert_current_date_or_time DateAndTime () the redraw echohl WarningMsg echo strfTime (" ⏰ now time %Y-%m-%d %H:% m :%S ⏰ ") echohl NONE endFunction nnoremap < m-t > :call DateAndTime()<CR> Iab xtime <c-r>=strftime("%Y-%m-%d %H:% m :%S")<cr>Copy the code

Day03

Originally yesterday thought to solve the problem of the key, but in fact it is not like this, yesterday just happened to be able to trigger, and can not be triggered at any time, the real impact of the key function is caused by a word

Set timeoutlen=1 ttimeoutlen=0 set timeoutlen=1 ttimeoutlen=0Copy the code

After the removal of the relevant combination of keys can now be used normally

The configuration has been submitted to Github

Now finally can formally enter Vim and some custom keys belong to their own, happy, the following days is to learn fast jump, there are Windows to switch related things, and Vim shortcut training

Vim-Go

Download the Go installation package from the Go website and configure environment variables in your.zshrc file

export PATH=$HOME/bin:/usr/local/go/bin:$PATH
Copy the code

Add in init.vim

" Vim-GO
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Copy the code

Then in Vim :GoInstallB… Could not find ‘guru’. Run :GoInstallBinaries to fix it

 go get   golang.org/x/tools/cmd/guru
 go build golang.org/x/tools/cmd/guru
 mv guru $(go env GOROOT)/bin
Copy the code

Day04

  • Vim-Ranger
" Vim-Ranger
Plug 'francoiscabrol/ranger.vim'
Plug 'rbgrouleff/bclose.vim'
Copy the code
  • Vim-Rainbow
" Rainbow
Plug 'luochen1990/rainbow'
Copy the code
  • Vim-css-color
" Color
Plug 'ap/vim-css-color'
Copy the code

= = = = = = =

  • Vim-surround

Quick add symbol plug-in

Normal mode

ds – delete a surrounding cs – change a surrounding ys – add a surrounding yS – add a surrounding and place the surrounded text on a new line + indent it yss – add a surrounding to the whole line ySs – add a surrounding to the whole line, place it on a new line + indent it ySS – same as ySs

Visual mode

s   – in visual mode, add a surrounding S   – in visual mode, add a surrounding but place text on new line + indent it

Insert mode

– In insert mode, add a surrounding – in insert mode, add a new line + surrounding + indent s-same as s-same as example

Copy the code