gpt4 book ai didi

c++ - Project Explorer ,Mini buf expl 在 VIM 中的使用

转载 作者:搜寻专家 更新时间:2023-10-31 01:23:59 25 4
gpt4 key购买 nike

在 VIM 中使用项目浏览器有什么技巧吗?如何从项目中的所有文件中搜索?我试过\g\G 但它们不起作用。

如何打开关闭项目浏览器窗口?

我正在使用 Project explorer 和 taglist,当我同时打开这两个窗口时,左侧有两个窗口,这使得非常困惑。是否可以像在 visual studio 中那样在右侧打开 taglist。

我也在使用 mini buf explorer ?我知道缓冲区可以用 :bd 关闭,但是如何关闭迷你缓冲区??

如果你们使用 C++,请发布您的 vimrc ..

我是 VIM 的新手,正在学习阶段。您的技巧可能会有所帮助...

最佳答案

我经常使用 vimctags 编写 C++ 代码。这是我的 dot.vimrc:

set backspace=indent,eol,start 
set completeopt=preview,menu
set nocompatible
set nofoldenable
set novisualbell
set expandtab
set foldlevel=0
set autowrite
set hlsearch
set showcmd
set showmode
set wildmenu
set pastetoggle=<F12>
set history=500
set mouse=a
set ruler
set cino=l1g0t0p0i0+0:0(0{0
"set ignorecase
set incsearch
set magic
set t_Co=256

" omnicppcomplete
"
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_NamespaceSearch = 2
let OmniCpp_DisplayMode = 1
let OmniCpp_ShowScopeInAbbr = 0
let OmniCpp_ShowPrototypeInAbbr = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_MayCompleteDot = 1
let OmniCpp_MayCompleteArrow = 1
let OmniCpp_MayCompleteScope = 0
let OmniCpp_SelectFirstItem = 0
let OmniCpp_LocalSearchDecl = 0
let OmniCpp_DefaultNamespaces = ['std', '_GLIBCXX_STD', 'tr1', '__gnu_cxx', 'generic', 'more']

" other features
"
if v:version >= 600
filetype plugin on
filetype indent on
else
filetype on
endif

if has("syntax")
syntax on
endif

" automatic commands
"
if has("autocmd")
autocmd BufEnter * set cindent comments=""
autocmd FileType make set noexpandtab shiftwidth=8
autocmd FileType c map <buffer> <leader><space> :w<cr>:!gcc %<cr> -I . -Wall
autocmd FileType c call UserSpaceMode() | set shiftwidth=4 ts=4 iskeyword=a-z,A-Z,48-57,_
autocmd FileType cpp call UserSpaceMode() | set shiftwidth=4 ts=4 iskeyword=a-z,A-Z,48-57,_,:
autocmd FileType cpp map <buffer> <leader><space> :w<cr>:!g++ %<cr> -I . -Wall
autocmd FileType cpp map <C-]> :exe "tj /.*" . expand("<cword>") . "$" <cr>
endif

" tab code completition with SuperTab
"
if version >= 700
let g:SuperTabDefaultCompletionType = "<C-X><C-P>"
highlight clear
highlight Pmenu ctermfg=0 ctermbg=2 gui=NONE
highlight PmenuSel ctermfg=0 ctermbg=7 gui=NONE
highlight PmenuSbar ctermfg=7 ctermbg=0 gui=NONE
highlight PmenuThumb ctermfg=0 ctermbg=7 gui=NONE

if has("gui_running")
colorscheme inkpot
else
colorscheme default
endif

endif


" ctags options
"
let my_err_counter = 0
let my_space_counter = 1
let my_extra_path = [ '/usr/include/c++/4.3/' ]
let my_ctags_options = [ '--languages=C,C++', '--c++-kinds=+p',
\'--fields=+iaS', '--extra=+q', '-I __THROW,__NTH,__wur,__warnattr,
\__nonnull,__attribute_malloc__,__attribute_pure__,__attribute_used__,
\__attribute_noinline__,__attribute_deprecated__,__attribute_format_arg__,
\__attribute_format_strfmon__,__attribute_warn_unused_result__,__always_inline,
\__extern_inline,__extension__,__restrict' ]

" ctags functions
"
function! UpdateExtraTags()
execute ":!ctags " . join(g:my_ctags_options,' ') . " -V -R -f ~/.vim/extratags " . join(g:my_extra_path, ' ')
echohl StatusLine | echo "Extra tags updated" | echohl None
endfunction

function! UpdateTags()
execute ":!ctags -V -R " . join(g:my_ctags_options, ' ')
echohl StatusLine | echo "C/C++ tag updated" | echohl None
endfunction

" user/kernel-space tags switcher
"
function! UserSpaceMode()
set tags=tags,~/.vim/extratags
endfunction
function! KernelSpaceMode()
set tags=tags,/usr/src/linux/tags
endfunction

function! SwitchSpaceMode()
let g:my_space_counter+=1
if (g:my_space_counter%2)
call UserSpaceMode()
echohl StatusLine | echo "userspace-tags mode" | echohl None
else
call KernelSpaceMode()
echohl StatusLine | echo "kernelspace-tags mode" | echohl None
endif
endfunction

function! SwitchErrMode()
let g:my_err_counter+=1
if (g:my_err_counter%2)
copen
else
cclose
endif
endfunction

" diff the current buffer with its unmodified version in the filesystem
"
function! s:DiffWithSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
com! DiffSaved call s:DiffWithSaved()

" insert c/c++ gates
"
function! s:insert_gates()
let gatename = "_" . substitute(toupper(expand("%:t")), "[\\.-]", "_", "g") . "_"
execute "normal! ggI#ifndef " . gatename
execute "normal! o#define " . gatename . " "
execute "normal! Go#endif /* " . gatename . " */"
normal! kk
endfunction

" insert namepsace c++
"
function! s:insert_namespace()
call inputsave()
let ns = inputdialog("namespace? ")
call inputrestore()
execute "normal! Anamespace " . ns . " { "
execute "normal! o} // namespace " . ns
normal! kk
endfunction

" insert c++ class
"
function! s:insert_class()
call inputsave()
let classname = inputdialog("ClassName? ")
call inputrestore()
execute "normal! iclass " . classname
execute "normal! o{ "
execute "normal! opublic:"
execute "normal! o" . classname . "()"
execute "normal! o{}"
execute "normal! o"
execute "normal! o~" . classname . "()"
execute "normal! o{}"
execute "normal! o"
execute "normal! oprivate:"
execute "normal! o"
execute "normal! o// non-copyable idiom"
execute "normal! o" . classname . "(const " . classname "&);"
execute "normal! o" . classname . " & operator=(const " . classname "&);"
execute "normal! o"
execute "normal! o};"
endfunction

" insert c++ value class
"
function! s:insert_value_class()
call inputsave()
let classname = inputdialog("ValueClassName? ")
call inputrestore()
execute "normal! iclass " . classname
execute "normal! o{ "
execute "normal! opublic:"
execute "normal! o" . classname . "()"
execute "normal! o{ /* implementation */ }"
execute "normal! o"
execute "normal! o~" . classname . "()"
execute "normal! o{ /* implementation */ }"
execute "normal! o"
execute "normal! o" . classname . "(const " . classname "&)"
execute "normal! o{ /* implementation */ }"
execute "normal! o"
execute "normal! o" . classname . " & operator=(const " . classname "& value)"
execute "normal! o{ /* implementation: " . classname . " tmp(value); swap(value); */"
execute "normal! oreturn *this;"
execute "normal! o}"
execute "normal! o"
execute "normal! o" . classname . " & operator@=(const " . classname . " &)"
execute "normal! o{ /* implementation */"
execute "normal! oreturn *this;"
execute "normal! o}"
execute "normal! o"
execute "normal! ofriend const " . classname . " operator@(" . classname . " lhs, const " . classname . " &rhs)"
execute "normal! o{ return lhs@=rhs; }"
execute "normal! o"
execute "normal! o" . classname . " & operator++()"
execute "normal! o{ /* implementation*/"
execute "normal! oreturn *this;"
execute "normal! o}"
execute "normal! o"
execute "normal! o" . classname . " & operator++(int)"
execute "normal! o{"
execute "normal! o" . classname . " tmp(*this);"
execute "normal! o++(*this);"
execute "normal! oreturn tmp;"
execute "normal! o}"
execute "normal! o"
execute "normal! oprivate:"
execute "normal! o"
execute "normal! o};"
endfunction

"autocmd BufNewFile *.{h,hpp} call <SID>insert_gates()

" abbreviate...
"
iab intmain int<cr>main(int argc, char *argv[])<cr>{<cr>return 0;<cr>}<cr>
iab #i #include <><Left>
iab #d #define
iab __P __PRETTY_FUNCTION__
iab __F __FUNCTION__

" set mapleader
"
let mapleader = ","

" keyboard mappig
"
map <F1> :call <SID>insert_gates() <cr>
map <F2> :call <SID>insert_namespace() <cr>
map <F3> :call <SID>insert_class() <cr>
map <F4> :call <SID>insert_value_class() <cr>

map <F5> :call SwitchSpaceMode() <cr>
map <F7> :make<cr>
map <F8> :call SwitchErrMode() <cr>

map <F9> :call UpdateTags() <cr>
map <F10> :call UpdateExtraTags() <cr>
map <F11> :call <SID>DiffWithSaved() <cr>

map <leader>e :e ~/.vimrc<cr> " edit vimrc
map <leader>u :source ~/.vimrc<cr> " update vimrc

map <tab> :tabnext<cr>
map <S-tab> :tabprevious<cr>

" plugins
"
runtime! ftplugin/man.vim
runtime! ftplugin/gzip.vim
runtime! ftplugin/taglist.vim

编码愉快! :-)

关于c++ - Project Explorer ,Mini buf expl 在 VIM 中的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/291611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com