首先,打開電腦終端并執行以下命令安裝Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
更多關于Homebrew, 大家可以訪問官網:https://brew.sh/
安裝Vim:
brew install vim
安裝Vim插件:Vundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
如果您的電腦上還沒安裝git就先執行以下命令安裝:
brew install git
創建.vimrc文件于根目錄
touch ~/.vimrc
將以下這些代碼復制并粘貼至剛剛創建的.vimrc文件中的最頂部
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)
" ...
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
然后運行:
:PluginInstall
之后您就可以以此類推安裝各種各樣的插件了,
此文不能將所有插件一一列出,但可推薦對于Python開發非常有用的一些。
分屏布局:
橫屏命令:
:sp <文件名>
豎屏命令:
:vs <文件名>
可設置分屏為向下或向右分:
set splitbelow
set splitright
代碼伸縮功能:(詳情:https://vim.fandom.com/wiki/Folding)
set foldmethod=indent
set foldlevel=99
用空格鍵快速執行伸縮命令:
" Enable folding with the spacebar
nnoremap <space> za
準確伸縮插件:
Plugin 'tmhedberg/SimpylFold'
添加之后執行安裝命令:
:PluginInstall
添加可見代碼伸縮:
let g:SimpylFold_docstring_preview=1
支持UTF-8
set encoding=utf-8
PEP 8規范查看:
Plugin 'nvie/vim-flake8'
美化代碼:
let python_highlight_all=1
syntax on
編輯器主題:
Plugin 'morhetz/gruvbox'
文件瀏覽:
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
let NERDTreeIgnore=['.pyc$', '~$'] "ignore files in NERDTree
超級搜索:
Plugin 'kien/ctrlp.vim'
Git集成
Plugin 'tpope/vim-fugitive'
狀態條
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
如果您嫌煩,直接訪問以下地址粘貼復制設置即可:
https://github.com/wangold/vim-config/blob/master/vimrc