首先,打开电脑终端并执行以下命令安装Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
更多关于Homebrew, 大家可以访问官网:https://brew.sh/
安装Vim:
brew install vim
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
如果您的电脑上还没安装git就先执行以下命令安装:
brew install git
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