分享我的 VIM 配置信息
本文最后更新于 3767 天前,其中的信息可能已经有所发展或是发生改变。

最近定制终端顺手把 Vim 也给摸索了一下。发现这传说中的「编辑器之神」果然不是浪得虚名啊。用一句时下流行的词语形容就是:狂拽酷炫屌炸天!

在 Mac OS X下除了终端直接调用 Vim 外,我还另外安装了 MacVim.app 。共享同一个配置文件: ~/.vimrc

QQ20130802-1

以下是我的 .vimrc 配置信息:

[code lang=”bash”]
set nocompatible " 取消兼容模式
set encoding=utf-8 " 编码格式
set langmenu=zh_cn " 菜单语言

" 开启插件功能
execute pathogen#infect()
syntax on
filetype plugin indent on

nmap <F8> :TagbarToggle<CR> " 插件Tagbar
map <C-n> :NERDTreeToggle<CR> " 快捷键打开NERDTree

" Solarized皮肤设置
syntax enable
set background=dark
colorscheme solarized

" 当打开GUI窗口VIM时运行
if has("gui_running")
winpos 5 25 " 窗口位置
set lines=55 columns=110 " 窗口界面的宽高
set guifont=Source_Code_Pro_Light:h12 " 英文字体
set guifontwide=Yuanti_SC_Light:h10.5 " 中文字体
" 可以在buffer的任何地方使用鼠标
set mouse=a
set selection=exclusive
set selectmode=mouse,key
endif

" 高亮显示当前输入行
autocmd InsertLeave * se nocul
autocmd InsertEnter * se cul

set history=100 " 保留历史记录
set confirm " 在处理未保存或只读文件的时候,弹出确认
set encoding=utf-8 " 编码格式
set wrap " 自动换行
set nu " 显示行号
set ruler " 打开状态栏标尺
set rulerformat=%15(%c%V\ %p%%%) " 标尺显示格式
set showmatch " 高亮显示对应的括号
set matchtime=5 " 对应括号的高亮时间
set autoindent " 自动对齐
set expandtab " 输入Tab自动转换称空格
set tabstop=4 " 设定tab长度为4
set shiftwidth=4 " 设定缩进的宽度为4
set nowrapscan " 禁止搜索到文件两端时重新搜索
set showcmd " 状态栏显示目前所执行的指令
set noeb " 关闭输入错误的提示音

" 总是显示状态栏
set ls=2
" 状态栏显示的内容
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"20%y/%m/%d\ -\ %H:%M\")}

" 进入插入模式时改变状态栏颜色(仅限于Vim 7)
if version >= 700
au InsertEnter * hi StatusLine guibg=#004C75 guifg=#FFFFFF gui=none
au InsertLeave * hi StatusLine guibg=#524E5C guifg=#CBCBCD gui=none
endif

" 查找时忽略大小写
set ignorecase
set incsearch
set hlsearch

set completeopt=preview,menu " 代码补全

" 符号自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(‘)’)<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair(‘}’)<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(‘]’)<CR>
:inoremap " ""<ESC>i
:inoremap ‘ ”<ESC>i
function! ClosePair(char)
if getline(‘.’)[col(‘.’) – 1] == a:char
return "\<Right>"
else
return a:char
endif
endfunction

" 打开文件类型检测, 加了这句才可以用智能补全
set completeopt=longest,menu

" 缩进插件
let g:indent_guides_guide_size=1
"nmap <silent> <Leader>ig <Plug>IndentGuidesToggle

" Pyflakes插件
let g:pyflakes_use_quickfix = 0

" 新建.py文件在开头自动添加内容
function HeaderPython()
call setline(1, "#!/usr/bin/python")
call append(1, "# -*- coding: utf-8 -*-")
normal G
normal o
normal o
endf
autocmd bufnewfile *.py call HeaderPython()
[/code]

安装的插件有:

Tagbar: http://www.vim.org/scripts/script.php?script_id=3465

Indent Guides: http://www.vim.org/scripts/script.php?script_id=3361

pyflakes: http://www.vim.org/scripts/script.php?script_id=2441

NERD tree: http://www.vim.org/scripts/script.php?script_id=1658

indent/python.vim: http://www.vim.org/scripts/script.php?script_id=3461

python.vim: http://www.vim.org/scripts/script.php?script_id=790

最后推荐几个不错的与 Vim 相关的网站:

VimTips: http://vim-tips.com/

Vimer的程序世界: http://www.vimer.cn/

Vim学习笔记: http://mturing.com/wiki/wikihtml/Vim%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0.html

本作品采用 “知识共享署名-非商业性使用 4.0 国际许可协议” 进行许可。
免责声明:本站文章除特殊说明为原创禁转外,您可以自由的转载和修改,但请务必注明文章来源并不可用于商业目的。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇