Vim 插件 主题

SpaceVim

1
curl -sLf https://spacevim.org/install.sh | bash

Vundle 插件管理器

Vundle 是Vim bundle 的简称,是一个 Vim 插件管理器.

Vundle 允许你做

  1. 在.vimrc中跟踪和管理插件
  2. 安装特定格式的插件(a.k.a. scripts/bundle)
  3. 更新特定格式插件
  4. 通过插件名称搜索Vim scripts中的插件
  5. 清理未使用的插件
  6. 可以通过单一按键完成以上操作,详见interactive mode

安装

1
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  • 配置
  1. 编辑
1
vim .vimrc
  1. 添加下列内容
1
2
3
4
5
6
7
set nocompatible   " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
call vundle#end() " required
filetype plugin indent on " required

安装需要的插件

  • bash 下:
1
vim +PluginInstall +qall
  • vim 下
1
:PluginInstall

安装 Markdown 插件

修改vimrc配置文件,添加

1
2
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'

下一步

1
2
vim
:PluginInstall

安装 gruvbox 主题

在 .vimrc 添加

1
2
Plugin 'morhetz/gruvbox'
Plugin 'vim-airline/vim-airline'

配置主题

1
2
3
4
set bg=dark "设置背景为黑色
colorscheme gruvbox "设置主题为 gruvbox
set guioptions= "去掉两边的scrollbar
set guifont=Monaco:h17 "设置字体和字的大小

Vim-airline

.vimrc 添加插件

1
2
Plugin 'vim-airline/vim-airline
Plugin 'vim-airline/vim-airline-themes'

配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"" airline settings.
let g:airline_theme = 'simple'
let g:airline_powerline_fonts = 1

if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif

let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
let g:airline#extensions#tabline#enabled = 1
" show absolute file path in status line
let g:airline_section_c = '%<%F%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'
" show tab number in tab line
let g:airline#extensions#tabline#tab_nr_type = 1

支持主题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
badwolf
base16
behelit
bubblegum
dark
durant
hybridline
hybrid
jellybeans
kalisi
kolor
laederon
light
lucius
luna
molokai
monochrome
murmur
papercolor
powerlineish
raven
serene
silver
simple
solarized
sol
term
tomorrow
ubaryd
understated
wombat
zenburn

NERD Tree 文件浏览插件

.vimrc 添加插件

1
Plugin 'scrooloose/nerdtree'

打开/关闭 NERD Tree

1
:NERDTreeToggle

NERD Tree 配置

1
2
3
4
5
"当 vim 启动没指定文件时,自动打开 NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"在 normal 下按 ,d 打开关闭文件浏览
nmap ,d :NERDTreeToggle<CR>

使用技巧

  1. ?可以打开 NERD tree 帮助文档
  2. j ,k 在 NERD tree上下移动,<c-r> 打开关闭文件夹或文件
  3. :vsp 在右侧打开一个分屏,:sp 在下面打开一个分屏
  4. <c-w>j<c-w>k, <c-w>h, <c-w>l按键分别向上、下、左、右分屏移动。 <c-w>=均分屏幕

改默的切换分屏按键方式

1
2
3
4
5
"--------- Split Mapping --------------------"
nmap <c-j> <c-w>j
nmap <c-k> <c-w>k
nmap <c-h> <c-w>h
nmap <c-l> <c-w>l

.vimrc 配置文件

vimrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"设置行号显示
set number

"将行号设置为相对行号
set relativenumber

"显示标尺
set ruler

" 编码
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set fileencoding=utf-8
set encoding=utf-8
set fencs=utf-8,gbk,gb2312,gb18030

"语法高亮
syntax enable
syntax on

" 高亮
hi pythonSelf ctermfg=174 guifg=#6094DB cterm=bold gui=bold
let python_highlight_all=1
syntax enable

" 状态行颜色
highlight StatusLine guifg=SlateBlue guibg=Yellow
highlight StatusLineNC guifg=Gray guibg=White

" 增强模式中的命令行自动完成操作
set wildmenu

" 总是显示状态行
set laststatus=2

"命令行补全参数
set wildmenu

"设置tab键空4格
set tabstop=4

"自动检测文件类型
filetype plugin indent on

"开启自动缩进,智能缩进
set autoindent
set cindent
set smartindent
set shiftwidth=4

"映射光标在窗口间移动的快捷键
nmap <C-H> <C-W>h
nmap <C-J> <C-W>j
nmap <C-K> <C-W>k
nmap <C-L> <C-W>l

"插件安装列表
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'morhetz/gruvbox'
Plugin 'vim-airline/vim-airline'
Plugin 'plasticboy/vim-markdown'
call vundle#end() " required
filetype plugin indent on " required

"基本主题配置
set bg=dark "设置背景为黑色
colorscheme gruvbox "设置主题为 gruvbox
set guioptions= "去掉两边的scrollbar
set guifont=Monaco:h17 "设置字体和字的大小
set cuc
set cul
set incsearch "输入搜索内容时就显示搜索结果
set ignorecase
set hlsearch "搜索时高亮显示被找到的文本

"airline settings.
let g:airline_theme = 'simple'
let g:airline_powerline_fonts = 1

if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif

let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
let g:airline#extensions#tabline#enabled = 1
" show absolute file path in status line
let g:airline_section_c = '%<%F%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'
" show tab number in tab line
let g:airline#extensions#tabline#tab_nr_type = 1

参考


本站由 VITAN 使用 Stellar 主题创建。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。