mac配置vim(python)

mac配置vim

Posted by Ysy on September 26, 2018

##前言

感觉用vim敲python代码很装逼,而且更锻炼使用linux,研究一下

安装vim并支持python3

mac自带的vim可能是不支持python3的,于是用brew手动安装一个 查看vim是否支持python3

In [1]: vim --version | grep python

+cryptv          +linebreak       +python/dyn      +vreplace
+cscope          +lispindent      -python3         +wildignore

python3 前面是- ,不支持python3,于是用brew手动安装一个

In [1]: brew install vim --with-python3
如果使用的还是系统自带vim,用brew安装一个东西
In [2]: brew install mercurial

现在查看应该支持python3了

自定义vim属性

设置vim主题颜色,首先可以去下载 http://www.easycolor.cc/vim/list.html 这个网站包含很多vim的主题

In [1]: git clone https://github.com/AlessandroYorba/Alduin.git
将下载下来的color文件放入到vim的color中,并修改.vimrc
colorscheme alduin

其余一些缩进等属性按照个人喜好设置

安装插件

首先需要安装的插件是管理vim插件的插件:Vundle 首先,下载插件

In [1]:git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
没有.vim/bundle目录就去创建目录

然后在~/.vimrc中添加一些配置

filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin '插件名(可以在github中查)'
call vundle#end()
filetype plugin indent on

在vim中执行命令,安装插件

In [1]: :PluginInstall

####具体插件介绍 YouCompleteMe 这个插件的主要作用就是代码补全,首先也是需要用Vundle来安装,他与其他插件不同的一点是需要手动编译

安装成功后需要进入目录、编辑
如果没有cmake需要先安装cmake
In [1]: brew install cmake
然后编译
In [1]: cd ~/.vim/bundle/YouCompleteMe
In [2]: python3 ./install.py --clang-completer
参数 --clang-completer是为了加上C系列语言的自动补全,如果不需要可以不加,它同时还支持其他语言的补全