Vim与Python的天作之合macOS配置

首先,打开电脑终端并执行以下命令安装Homebrew:

<code>/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"/<code>

更多关于Homebrew, 大家可以访问官网:https://brew.sh/

安装Vim:

<code>brew install vim/<code>

安装Vim插件:Vundle

<code>git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim/<code>

如果您的电脑上还没安装git就先执行以下命令安装:

<code>brew install git/<code>

创建.vimrc文件于根目录

<code>touch ~/.vimrc/<code>

将以下这些代码复制并粘贴至刚刚创建的.vimrc文件中的最顶部

<code>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/<code>

然后运行:

<code>:PluginInstall/<code>

之后您就可以以此类推安装各种各样的插件了,

此文不能将所有插件一一列出,但可推荐对于Python开发非常有用的一些。

分屏布局:

横屏命令:

<code>:sp /<code>

竖屏命令:

<code>:vs /<code>

可设置分屏为向下或向右分:

<code>set splitbelow
set splitright/<code>

代码伸缩功能:(详情:https://vim.fandom.com/wiki/Folding)

<code>set foldmethod=indent
set foldlevel=99/<code>

用空格键快速执行伸缩命令:

<code>" Enable folding with the spacebar
nnoremap <space> za/<space>/<code>

准确伸缩插件:

<code>Plugin 'tmhedberg/SimpylFold'/<code>

添加之后执行安装命令:

<code>:PluginInstall/<code>

添加可见代码伸缩:

<code>let g:SimpylFold_docstring_preview=1/<code>

支持UTF-8

<code>set encoding=utf-8/<code>

PEP 8规范查看:

<code>Plugin 'nvie/vim-flake8'/<code>

美化代码:

<code>let python_highlight_all=1
syntax on/<code>

<code>Plugin 'morhetz/gruvbox'/<code>

文件浏览:

<code>Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
let NERDTreeIgnore=['\\.pyc$', '\\~$'] "ignore files in NERDTree/<code>

超级搜索:

<code>Plugin 'kien/ctrlp.vim'/<code>

Git集成

<code>Plugin 'tpope/vim-fugitive'/<code>

状态条

<code>Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}/<code>

如果您嫌烦,直接访问以下地址粘贴复制设置即可:

https://github.com/wangold/vim-config/blob/master/vimrc