[关闭]
@Scrazy 2016-12-14T03:40:21.000000Z 字数 4319 阅读 1539

Vim 简单配置

vim


刚新装了 manjaro 于是,也重新配置下 Vim。先安装大杀器:

Vundle

$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

按照提示设置下。把下面一堆配置添加到 .vimrc

  1. set nocompatible " be iMproved, required
  2. filetype off " required
  3. " set the runtime path to include Vundle and initialize
  4. set rtp+=~/.vim/bundle/Vundle.vim
  5. call vundle#begin()
  6. " alternatively, pass a path where Vundle should install plugins
  7. "call vundle#begin('~/some/path/here')
  8. " let Vundle manage Vundle, required
  9. Plugin 'VundleVim/Vundle.vim'
  10. " The following are examples of different formats supported.
  11. " Keep Plugin commands between vundle#begin/end.
  12. " plugin on GitHub repo
  13. Plugin 'tpope/vim-fugitive'
  14. " plugin from http://vim-scripts.org/vim/scripts.html
  15. Plugin 'L9'
  16. " Git plugin not hosted on GitHub
  17. Plugin 'git://git.wincent.com/command-t.git'
  18. " git repos on your local machine (i.e. when working on your own plugin)
  19. Plugin 'file:///home/gmarik/path/to/plugin'
  20. " The sparkup vim script is in a subdirectory of this repo called vim.
  21. " Pass the path to set the runtimepath properly.
  22. Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
  23. " Install L9 and avoid a Naming conflict if you've already installed a
  24. " different version somewhere else.
  25. "Plugin 'ascenator/L9', {'name': 'newL9'}
  26. " All of your Plugins must be added before the following line
  27. call vundle#end() " required
  28. filetype plugin indent on " required
  29. " To ignore plugin indent changes, instead use:
  30. "filetype plugin on
  31. "
  32. " Brief help
  33. " :PluginList - lists configured plugins
  34. " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
  35. " :PluginSearch foo - searches for foo; append `!` to refresh local cache
  36. " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
  37. "
  38. " see :h vundle for more details or wiki for FAQ
  39. " Put your non-Plugin stuff after this line

我把第40行注释掉了,因为安装插件时报错。接下来就要安装本次要安装的插件啦以及简单配置。打开 Vundle 输入 :PluginInstall 回车即可。
[nerdtree]

主题

vim-monokai
在 .vimrc 添加

`colorscheme monokai`

即可。

缩进线

indentLine

格式化代码

vim-autopep8
安装完成后要

此插件默认 F8 触发,可以更换自己喜欢的键位,如:F3 把下面代码添加到 .vimrc 即可。

autocmd FileType python map <buffer> <F3> :call Autopep8()<CR>

顺便添加一句

let g:autopep8_disable_show_diff=1

以便让其不会每次都提示格式化前后的差异。

nerdtree 目录树

nerdtree
添加快捷启动方式

map <C-n> :NERDTreeToggle<CR>

置于 .vimrc 即可

这是我的 .vimrc

```bash
set nocompatible " be iMproved, 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 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
"Plugin 'ascenator/L9', {'name': 'newL9'}
" youcompleteme
Plugin 'Valloric/YouCompleteMe'
"Nerdtree
Plugin 'scrooloose/nerdtree'

Plugin 'sickill/vim-monokai'

"Plugin 'Lokaltog/vim-powerline'

Plugin 'Yggdroot/indentLine'

Plugin 'tell-k/vim-autopep8'

Plugin 'jiangmiao/auto-pairs'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append ! to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append ! to refresh local cache
" :PluginClean - confirms removal of unused plugins; append ! to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

"按F5运行python"
map :Autopep8 :w :call RunPython()
function RunPython()
let mp = &makeprg
let ef = &errorformat
let exeFile = expand("%:t")
setlocal makeprg=python\ -u
set efm=%C\ %.%#,%A\ \ File\ \"%f\"\,\ line\ %l%.%#,%Z%[%^\ ]%\@=%m
silent make %
copen
let &makeprg = mp
let &errorformat = ef
endfunction

syntax on
let g:molokai_original = 1
set clipboard=unnamedplus
set nu!
set t_Co=256
set encoding=utf-8

" 解决Vundle 安装插件时报错,仅限fish shell
set shell=/bin/bash
colorscheme monokai

" 配置autopep8
let g:autopep8_disable_show_diff=1
autocmd FileType python map :call Autopep8()

" indentLine
let g:indentLine_setColors = 0
let g:indentLine_char = '|'

" 目录树 nerdtree
map :NERDTreeToggle
```此处输入链接的描述
以上只是本人总结,并不详细,难免有错误和疏漏,详细文档可去官网进行查看。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注