vim 配置

xiaoxiao2021-02-27  318

Vundle.vim 用于管理插件,安装配置为:
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim 参考:https://github.com/VundleVim/Vundle.Vim 修改.vimrc 调用:vim +PluginInstall +qall 命令
YouCompleteMe 自动提示插件, 安装为:

安装依赖: sudo apt-get install build-essential cmake sudo apt-get install python-dev python3-dev 下载插件:

Plugin 'Valloric/YouCompleteMe'

编译插件,安装插件

cd ~/.vim/bundle/YouCompleteMe ./install.py --clang-completer cd ~/.vim/bundle/YouCompleteMe ./install.py cd ~/.vim/bundle/YouCompleteMe ./install.py --all 或 ./install.sh

参考:https://github.com/Valloric/YouCompleteMe

cscope 强大的搜索命令 apt install cscope cscope 不会遍历java,在~/.bashrc 添加函数,

ctag() { find -name "*.c" -o -name ".cpp" -o -name ".cc" -o -name ".h" -o -name "*.java" > cscope.files cscope -Rbq -i cscope.files ctags -R }

使用函数将cscope 与tab 有效的结合起来 按下ctrl +p(用以替代ctrl+p) 将在新的tab页中,打开光标对应的文件,如果光标处没有字符,那让用户输入。

function OpenFile (fileName) if (isdirectory(expand('%:h'))) execute 'tabnew' endif if empty(a:fileName) let l:fileName = input('FileName: ') if (!empty(l:fileName) ) execute 'cs find f ' l:fileName endif else execute 'cs find f ' a:fileName endif if (!isdirectory(expand('%:h'))) execute 'tabclose' execute 'tabprevious' endif endfunction "nmap <C-p> : call OpenFile("")<CR> map <C-p> : call OpenFile(expand("<cword>"))<CR>

cscope_maps.vim 为cscope 设置快捷键,以便在vim中使用 http://cscope.sourceforge.net/cscope_maps.vim

Tagbar 的安装

Plugin 'majutsushi/tagbar' "tagbar nmap <F2> :TagbarToggle<CR> let g:tagbar_autofocus = 1 let g:tagbar_width=30 let tagbar_left=1

Ctrlp 的安装 ctrl 可以使用cscope 与tab 替代

Plugin 'kien/ctrlp.vim'

Ctrl 的配置

let g:ctrlp_map = '<c-p>' let g:ctrlp_cmd = 'CtrlP' let g:ctrlp_working_path_mode = 'ra' let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/]\.(git|hg|svn|rvm)$', \ 'file': '\v\.(exe|so|dll|zip|tar|tar.gz)$', \ } "\ 'link': 'SOME_BAD_SYMBOLIC_LINKS', let g:ctrlp_user_command = 'find %s -type f' set wildignore+=*/tmp/*,*.so,*.swp,*.zip let g:ctrlp_working_path_mode=0 let g:ctrlp_match_window_bottom=1 let g:ctrlp_max_height=15 let g:ctrlp_match_window_reversed=0 let g:ctrlp_mruf_max=500 let g:ctrlp_follow_symlinks=1

CtrlPFunky 依赖ctrlp,用以查找当前文件中的函数 安装

Plugin 'tacahiroy/ctrlp-funky'

fu 进入当前文件的函数列表搜索

fU 搜索当前光标下单词对应的函数

Bundle 'tacahiroy/ctrlp-funky' nnoremap <Leader>fu :CtrlPFunky<Cr> " narrow the list down with a word under cursor nnoremap <Leader>fU :execute 'CtrlPFunky ' . expand('<cword>')<Cr> let g:ctrlp_funky_syntax_highlight = 1 let g:ctrlp_extensions = ['funky']

TAB页的使用 正常可以使用tabnew、tabclose、tabnext等名来实现,但是更建议配置一个快捷键:

nmap tn :tabnext<CR> nmap tp :tabprevious<CR>

vim-airline 安装 安装 vim-airline 加强状态栏

Plugin 'bling/vim-airline'

配置

let g:airline_powerline_fonts = 1

https://my.oschina.net/Julian1988/blog/140784

http://www.zlovezl.cn/articles/vim-plugins-cannot-live-without/

在 vim 中使用 cscope 时, : cs f s symbol-name 或相应的快捷键执行后当前窗口就跳转到引用该符号的位置。

如果想跳转的同时打开一个新的窗口,可以使用如下命令:

scs f s symbol-name

这里的 scs 应该是 split 的意思。

另外,上面这个命令是将窗口横向分割,如果要纵向分割的话,可以使用如下命令:

vert scs f s symbol-name

另外可以在 .vimrc 里追加对应的快捷键:

转载请注明原文地址: https://www.6miu.com/read-2014.html

最新回复(0)