1 Star 0 Fork 0

杨晓康/my_vim

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
.vimrc 14.60 KB
一键复制 编辑 原始数据 按行查看 历史
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
" debian.vim
"设置字符编码
set fenc=utf-8
set fencs=utf-8,gb18030,cp936,gbk,big5
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
set nocompatible
" Vim5 and later versions support syntax highlighting. Uncommenting the
" following enables syntax highlighting by default.
if has("syntax")
syntax on " 语法高亮
endif
set ttymouse=xterm2
if &term =~ "xterm"
" SecureCRT versions prior to 6.1.x do not support 4-digit DECSET
" let &t_ti = "\<Esc>[?1049h"
" let &t_te = "\<Esc>[?1049l"
" Use 2-digit DECSET instead
let &t_ti = "\<Esc>[?47h"
let &t_te = "\<Esc>[?47l"
endif
"colorscheme inkpot " elflord ron peachpuff default 设置配色方案,vim自带的配色方案保存在/usr/share/vim/vim72/colors目录下
if &diff
colorscheme inkpot
endif
" detect file type
filetype on
filetype plugin on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"have Vim load indentation rules and plugins according to the detected filetype
filetype plugin indent on
endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
" 不要高亮被搜索的句子(phrases)
"set nohlsearch
set hlsearch
" 自动格式化
set formatoptions=tcrqn
set ignorecase " 搜索模式里忽略大小写
set smartcase " 如果搜索模式包含大写字符,不使用 'ignorecase' 选项。只有在输入搜索模式并且打开 'ignorecase' 选项时才会使用。
set autowrite " 自动把内容写回文件: 如果文件被修改过,在每个 :next:rewind:last:first:previous:stop:suspend:tag:!:make、CTRL-] 和 CTRL-^命令时进行;用 :buffer、CTRL-O、CTRL-I、'{A-Z0-9} 或 `{A-Z0-9} 命令转到别的文件时亦然。
set autoindent " 设置自动对齐(缩进):即每行的缩进值与上一行相等;使用 noautoindent 取消设置
set smartindent " 智能对齐方式
" 不要换行
set wrap "换行用wrap 不换行为nowrap
set tabstop=4 " 设置制表符(tab键)的宽度
" 不要用空格代替制表符
"set noexpandtab
set expandtab
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++语言的具体缩进方式
"set backspace=2 " 设置退格键可用
set showmatch " 设置匹配模式,显示匹配的括号
set linebreak " 整词换行
set whichwrap=b,s,<,>,[,] " 光标从行首和行末时可以跳到另一行去
"set hidden " Hide buffers when they are abandoned
set number " Enable line number "显示行号 不显示用nonumber
"set previewwindow " 标识预览窗口
set history=50 " set command history to 50 "历史记录50
"在处理未保存或只读文件时弹出确认
set confirm
"与windows共享剪切板
set clipboard+=unnamed
"--状态行设置--
" 我的状态行显示的内容(包括文件类型和解码)
set statusline=%F%m%r%h%w\[POS=%l,%v][%p%%]\%{strftime(\"%d/%m/%y\ -\ %H:%M\")}
set laststatus=2 " 总显示最后一个窗口的状态行;设为1则窗口数多于一个的时候显示最后一个窗口的状态行;0不显示最后一个窗口的状态行
set ruler " 标尺,用于显示光标位置的行号和列号,逗号分隔。每个窗口都有自己的标尺。如果窗口有状态行,标尺在那里显示。否则,它显示在屏幕的最后一行上。
" 在状态行上显示光标所在位置的行号和列号
set rulerformat=%20(%2*%<%f%=\ %m%r\ %3l\ %c\ %p%%%)
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文件设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 不要备份文件(根据自己需要取舍)
set nobackup
" 不要生成swap文件,当buffer被丢弃的时候隐藏它
"setlocal noswapfile
set noswapfile
set bufhidden=hide
" 增强模式中的命令行自动完成操作
set wildmenu
" 命令行(在状态行下)的高度,默认为1,这里是2
set cmdheight=1
" 允许backspace和光标键跨越行边界
set whichwrap+=<,>,h,l
" 使回格键(backspace)正常处理indent, eol, start等
set backspace=2
" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=v " Enable mouse usage (all modes) "使用鼠标
let test=0
function MyFunc()
set mouse=v
if g:test > 0
set nonumber
let g:test = 0
else
set number
let g:test = 1
endif
endfunction
"map <C-c> :set mouse=v<CR>:set nonumber<CR>:TlistClose<CR>
map <C-c> :call MyFunc()<CR>
map <C-x> :set mouse=a<CR>:set number<CR>
set selection=exclusive
set selectmode=mouse,key
" 输入:set list命令是应该显示些啥?
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$
"光标移动到buffer的顶部和底部时保持3行距离
set scrolloff=3
" configure syntastic syntax checking to check on open as well as save
let g:syntastic_check_on_open=0
"let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_wq = 0
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
"let g:syntastic_check_on_open=1
"let g:syntastic_enable_signs=1
"let g:syntastic_cpp_include_dirs = ['/users/xk.yang/optee_os/lib/libutee/include', 'include']
"let g:syntastic_ignore_files = ['\m^/users/xk.yang/optee_os/lib/libutee/include', '\m\c\.h$']
"let g:syntastic_cpp_check_header = 1
"let g:syntastic_cpp_remove_include_errors = 1
" 不要闪烁
set novisualbell
" 在被分割的窗口间显示空白,便于阅读
set fillchars=vert:\ ,stl:\ ,stlnc:\
"--命令行设置--
set showcmd " 命令行显示输入的命令
set showmode " 命令行显示vim当前模式
"--find setting--
set incsearch " 输入字符串就显示匹配点
set hlsearch
"--ctags setting--
" 按下F5重新生成tag文件,并更新taglist
map <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
imap <F12> <ESC>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
if filereadable("tags")
set tags+=tags
else
let tags_file=findfile("tags", ".;")
if !empty(tags_file) && filereadable(tags_file)
exe 'set tags+='.tags_file
endif
endif
set tags+=/usr/include/c++/tags "add current directory's generated tags file
"set tags+=~/arm/linux-2.6.24.7/tags "add new tagsfile(刚刚生成tags的路径,在ctags -R生成tags文件后,不要将tags移动到别的目录,否则ctrl+]时,会提示找不到源码文件)
"配置彩虹括号
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
"去掉black 防止黑括号看不清
" \ ['black', 'SeaGreen3'],
let g:rbpt_max = 64
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
"我自己为函数列表增加的一个快捷键.
"map <F11> :Tlist <CR>
"
""-- Taglist setting --
"let Tlist_Ctags_Cmd='ctags' "因为我们放在环境变量里,所以可以直接执行
"let Tlist_Use_Right_Window=1 "让窗口显示在右边,0的话就是显示在左边
"let Tlist_Show_One_File=1 "让taglist可以同时展示多个文件的函数列表
"let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏
"let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim
""是否一直处理tags.1:处理;0:不处理
"let Tlist_Process_File_Always=1 "实时更新tags
"let Tlist_Inc_Winwidth=0 "如果在文本界面下运行vim,则将窗口长度设为0
map <F11> :TagbarToggle <CR>
" -- MiniBufferExplorer --
let g:miniBufExplMapWindowNavVim = 1 "按下Ctrl+h/j/k/l,可以切换到当前窗口的上下左右窗口
let g:miniBufExplMapWindowNavArrows = 1 "按下Ctrl+箭头,可以切换到当前窗口的上下左右窗口
let g:miniBufExplMapCTabSwitchBufs = 1 "启用以下两个功能:Ctrl+tab移到下一个buffer并在当前窗口打开;Ctrl+Shift+tab移到上一个buffer并在当前窗口打开;ubuntu好像不支持
"let g:miniBufExplMapCTabSwitchWindows = 1 "启用以下两个功能:Ctrl+tab移到下一个窗口;Ctrl+Shift+tab移到上一个窗口;ubuntu好像不支持
let g:miniBufExplModSelTarget = 1 "不要在不可编辑内容的窗口(如TagList窗口)中打开选中的buffer
"--fold setting--
set foldmethod=syntax " 用语法高亮来定义折叠
set foldlevel=100 " 启动vim时不要自动折叠代码
"set foldcolumn=0 " 设置折叠栏宽度
"--为了适应这个脚本 自动加载cscope数据库而加的设置(autoload_cscope.vim)
set nocst "在cscope数据库添加成功的时候不在命令栏现实提示信息.
set cspc=6 "cscope的查找结果在格式上最多显示6层目录.
let g:autocscope_menus=0 "关闭autocscope插件的快捷健映射.防止和我们定义的快捷键冲突.
"-- Nerdtree setting --
"map <F2> :NERDTreeToggle<CR>
"map <F2> :NERDTreeFind<CR>
"let NERDTreeChDirMode=2 "选中root即设置为当前目录
"let NERDTreeQuitOnOpen=1 "打开文件时关闭树
"let NERDTreeShowBookmarks=1 "显示书签
"let NERDTreeMinimalUI=1 "不显示帮助面板
"let NERDTreeDirArrows=0 "目录箭头 1 显示箭头 0传统+-|号
"3.自定义选项
"--------------------------------------------------------------------------------
"loaded_nerd_tree 不使用NerdTree脚本
"NERDChristmasTree 让Tree把自己给装饰得多姿多彩漂亮点
"NERDTreeAutoCenter 控制当光标移动超过一定距离时,是否自动将焦点调整到屏中心
"NERDTreeAutoCenterThreshold 与NERDTreeAutoCenter配合使用
"NERDTreeCaseSensitiveSort 排序时是否大小写敏感
"NERDTreeChDirMode 确定是否改变Vim的CWD
"NERDTreeHighlightCursorline 是否高亮显示光标所在行
"NERDTreeHijackNetrw 是否使用:edit命令时打开第二NerdTree
"NERDTreeIgnore 默认的“无视”文件
"NERDTreeBookmarksFile 指定书签文件
"NERDTreeMouseMode 指定鼠标模式(1.双击打开;2.单目录双文件;3.单击打开)
"NERDTreeQuitOnOpen 打开文件后是否关闭NerdTree窗口
"NERDTreeShowBookmarks 是否默认显示书签列表
"NERDTreeShowFiles 是否默认显示文件
"NERDTreeShowHidden 是否默认显示隐藏文件
"NERDTreeShowLineNumbers 是否默认显示行号
"NERDTreeSortOrder 排序规则
"NERDTreeStatusline 窗口状态栏
"NERDTreeWinPos 窗口位置('left' or 'right')
"NERDTreeWinSize 窗口宽
"我的配置:
"NERD Tree
"let NERDChristmasTree=1
"let NERDTreeAutoCenter=1
"let NERDTreeMinimalUI=1 "不显示帮助面板
let NERDTreeDirArrows=0 "目录箭头 1 显示箭头 0传统+-|
"let NERDTreeBookmarksFile=$VIM.'\Data\NerdBookmarks.txt'
"let NERDTreeMouseMode=2
"let NERDTreeShowBookmarks=1
"let NERDTreeShowFiles=1
"let NERDTreeChDirMode=2 "选中root即设置为当前目录
"let NERDTreeShowHidden=1
"let NERDTreeShowLineNumbers=1
"let NERDTreeWinPos='left'
"let NERDTreeWinSize=31
nnoremap <F10> :NERDTreeToggle <CR>
if has("cscope")
"set csprg=/users/xk.yang/vim/bin/cscope " 指定用来执行cscope的命令
set csto=0 " 设置cstag命令查找次序:0先找cscope数据库再找标签文件;1先找标签文件再找cscope数据库
set cst " 同时搜索cscope数据库和标签文件
"set cscopequickfix=s-,c-,d-,i-,t-,e- " 使用QuickFix窗口来显示cscope查找结果
"set cscopequickfix=s-,c-,i-,t-,e- " 使用QuickFix窗口来显示cscope查找结果
let csdb_name="cscope.out"
"let csdb_name="GTAGS"
set nocsverb
"if filereadable("cscope.out") " 若当前目录下存在cscope数据库,添加该数据库到vim
" cs add cscope.out
"elseif $CSCOPE_DB != "" " 否则只要环境变量CSCOPE_DB不为空,则添加其指定的数据库到vim
" cs add $CSCOPE_DB
"endif
if filereadable(csdb_name)
exe "cs add" csdb_name
else
let cscope_file=findfile(csdb_name, ".;")
let cscope_pre=matchstr(cscope_file, ".*/")
if !empty(cscope_file) && filereadable(cscope_file)
exe "cs add" cscope_file
"exe "cs add" cscope_file cscope_pre
endif
endif
set csverb
endif
"个人c329 scope的快捷键映射
""cscope相关的快捷键映射
nmap ff <c-]>
"s:查找即查找C语言符号出现的地方
nmap fs :cs find s <C-R>=expand("<cword>")<CR><CR>
""g:查找函数、宏、枚举等定义的位置
nmap fr :cs find g <C-R>=expand("<cword>")<CR><CR>
"c:查找光标下的函数被调用的地方
nmap fc :cs find c <C-R>=expand("<cword>")<CR><CR>
""t: 查找指定的字符串出现的地方
nmap ft :cs find t <C-R>=expand("<cword>")<CR><CR>
"e:egrep模式查找,相当于egrep功能
nmap fe :cs find e <C-R>=expand("<cword>")<CR><CR>
""f: 查找文件名,相当于lookupfile
nmap fn :cs find f <C-R>=expand("<cfile>")<CR><CR>
"i: 查找当前文件名出现过的地方
nmap fi :cs find i <C-R>=expand("<cfile>")<CR><CR>
""d: 查找本当前函数调用的函数
nmap fd :cs find d <C-R>=expand("<cword>")<CR><CR>
nmap fg :vim /<C-R><C-W>/ **/*.[h,cpp] <CR><CR>
nmap lt :set invlist<cr>
"删除行尾空格
nmap lk <CR>:%s/\s*$//g<CR>
"table用4空格替换
"nmap ,k <CR>:%s/\t/ /g<CR>
"删除^M 的命令快捷键不起作用不知道为什么
"nmap lm <CR>:%s/^M//g<CR>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
VimL
1
https://gitee.com/eagle_ice/my_vim.git
git@gitee.com:eagle_ice/my_vim.git
eagle_ice
my_vim
my_vim
master

搜索帮助