Vim配置文件
Vim配置文件
Vim配置文件
Vim的配置
Vim本身的系统配置文件夹是在/usr/share/vim/和/etc/vim/两个文件夹下。一般情况下,我们不会去改变这两个文件夹下的配置文件,而是在用户文件夹/home/user(其中,user为用户名)下建立自己的配置文件。进入用户文件夹(/home/user/)之后,用gedit新建一个名叫.vimrc的文件(进入终端):
$ cd \~
$ gedit .vimrc
注:使用gedit主要是为了方便大段大段的文字粘贴 然后把下面的文字拷贝进这个文件之后保存
" Configuration file for vim
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " 去除VI一致性,不然没有vim特性
filetype off " 必须
下面这段是配置vundle所需的配置段
" 设置包括vundle和初始化相关的runtime path
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" 另一种选择, 指定一个vundle安装插件的路径
"call vundle#begin('~/some/path/here')
" 请将安装插件的命令放在vundle#begin和vundle#end之间.
" Github上的插件
" 格式为 Plugin '用户名/插件仓库名'
" 让vundle管理插件版本,必须
Plugin 'VundleVim/Vundle.vim'
Plugin 'tczengming/autoload_cscope.vim'
" 你的所有插件需要在下面这行之前
call vundle#end() " 必须
filetype plugin indent on " 必须 加载vim自带和插件相应的语法和文件类型相关脚本
" 忽视插件改变缩进,可以使用以下替代:
"filetype plugin on
"
" 简要帮助文档
" :PluginList - 列出所有已配置的插件
" :PluginInstall - 安装插件,追加 `!` 用以更新或使用 :PluginUpdate
" :PluginSearch foo - 搜索 foo ; 追加 `!` 清除本地缓存
" :PluginClean - 清除未使用插件,需要确认; 追加 `!` 自动批准移除未使用插件
开始个性配置
set backspace=2 " more powerful backspacing
" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.\* set nowritebackup nobackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.\* set nowritebackup nobackup
set bg=dark
set hlsearch "高亮匹配项
set autoindent " always set autoindenting on
set nu " 显示行号
set relativenumber " 相对行号
set showmatch " 设置匹配模式,显示匹配的括号
set shiftwidth=4
set tabstop=4 " 设置制表符(tab键)的宽度
set softtabstop=4 " 设置软制表符的宽度
set shiftwidth=4 " (自动) 缩进使用的4个空格
set cindent " 使用 C/C\++ 语言的自动缩进方式
set cinoptions=\{0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s "设置C/C\++语言的具体缩进方式
colorscheme koehler
set gfn=Osaka-Mono:h20
set tabstop=4
set transparency=10 "macvim独有的透明特效
set backspace=indent,eol,start
set foldmethod=syntax "使用语法高亮定义代码折叠
set foldlevelstart=99 "默认代码不折叠
set tags=tags; "不断递归向上查找tags
set showcmd "显示正在输入的命令
set clipboard=unnamed "共用系统剪贴板
下面是配置一些快捷键
"==========快捷键=========
" 调用lldb进行单步调试
map <D-8> call LLDB()<CR>
func! LLDB()
exec "w"
exec "!lldb %<.out"
endfunc
" 调用gcc编译单文件
map <D-9> call Comm()<CR>
func! Comm()
exec "w"
exec "!gcc %<.c -o %<.out -g -Wall"
exec "! %<.out"
endfunc
"========插件特殊配置========
" autoload_cscope
let g:autocscope_menus=0 "关闭autoload_cscope的快捷键映射
nmap fc :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap ft :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <Down> :cnext<CR>
nmap <Up> :cprev<CR>