Yesterday, I saw Chi Jianqiang's "MacTalk Life Metaprogramming" on WeChat Reading, and then spent almost a day reading it. One of the articles about Vim brought up my interest in this editor again (yes, I Interested in it many times, lazy every time..).
I've been too lazy to configure it slowly, and I don't want to use someone else's configuration. The editor I use still wants to toss it myself, and then I hurriedly tossed it today while I still have a little enthusiasm for this.
In fact, writing code directly on the command line is a bit unaccustomed, so I chose the GUI version of MacVim. In this way, it can be opened separately like other editors, and when you want to make small changes to the code, you can directly open the command line.
In the MacTalk article, there is a mention of the Chinese version of Vimhelp documentation, then download it. Sure enough, the Chinese is relatively easy to understand.
seen others before
.vimrcConfiguration, there are some basic configurations of editors, and I don't know where to find them. It turns out that these configurations can be entered in the editor
:help optionsto view.
Regarding the configuration of indentation, the main settings are
expandtabthese three options.
autoindentoption determines the indentation of new lines based on the previous line
smartindentOption smart auto-indent
expandtaboption convert tabs to spaces
set autoindent set smartindent set expandtab
Displaying line numbers is a hard requirement, but unlike other editors, there are also relative line numbers on vim.
set number set relativenumber
Obviously, installing vim plugins manually is a hassle and hassle. Similar to sublime text and the like, vim also has a similar plugin managerVundle。
~/.vimand config file
~/.vimrc, and install Vundle:
$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
Create a new one for easier management
.vimrc.bundlesTo store the list of plugins separately:
set nocompatible " be iMproved, required filetype off " requried set rtp+=~/.vim/bundle/vundle/ call vundle#begin() " Let Vundle manage Vundle Bundle 'gmarik/vundle' " .... other plugins call vundle#end() " required filetype plugin indent on
When adding plugins in the future, you only need to add a line to this file:
Install plugin input
:BundleInstallcommand, delete the corresponding configuration when uninstalling the plugin and run
:BundleCleanRemove the plugin.
When using it for the first time, enter
(I didn't even pop out another one by myself.
). This is not scientific, it is necessary to be reasonable.
found that many people usedelimitMate,Add to
After the installation is complete, the brackets can be automatically completed.
Many browsers support the Emmet plugin, and so does vim. But this Emmet is a third party, calledEmmet.vim。
After installation, it is mainly to set the shortcut key for departure. The default shortcut key is
Ctrl + y。
I changed the shortcut key to
Ctrl + erelatively easy.
" Emmet.vim let g:user_emmet_expandabbr_key = '<c-e>'
The directory tree is basically just usingNERDTree。
The shortcut key to open the directory tree is changed to
Ctrl + b, and then automatically exit when vim is left with only the directory tree displayed.
" NERDTree map <c-b> :NERDTreeToggle<CR> autocmd vimenter * NERDTree autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") &&b:NERDTreeType == "primary") | q | endif
Complementation is well-knownYouCompleteMe.
There are many plug-ins on the Internet about this plug-in, so I won't dwell on it. Here is mainly the configuration of Baidu EFE copied:
After tossing for an afternoon, it was finally done. In fact, the process is quite fun, and if there is a chance, I want to write a plug-in to play.
After that, I abandoned VS Code and started the journey of Vim to experience the feeling of high efficiency without leaving my hands on the keyboard.