Mainly because of Loongson computers… everyone knows about it… In addition, ceph runs on the server and can only be accessed through ssh. It is not easy to debug and read the code. So there is the following tossing
If a worker wants to do his job well, he must first sharpen his tools.
1. Overview of VIM
VIM is a text editor on Linux system. It is a powerful tool for operating Linux.
Currently, many excellent IDEs support the installation of VIM plug-ins. The reason is that using it is convenient, efficient, and fun!
To create a vim editor as shown below, you mainly need to combine a series of vim plug-ins and configure the .vimrc file.
On the left is the NERD_tree plug-in 1, on the right is the Tag_List plug-in, and below is the SrcExl plug-in
2. Configuration steps
I will create the vim effect shown above step by step from a vim editor with no configuration at all.
1. Download the required plug-ins. I only give an example of one plug-in here.
- Enter the vim official website and find the plug-in you want to download.
- Search for the plug-in you want, as shown in the picture, download the zip package, put the zip package in the ~/.vim folder and unzip it, so that the plug-in can be used, and the plug-in also has its own The corresponding usage method will not be described in detail. (If you don’t have one, create one yourself). Of course, you can also download the plug-in from github, or use vim’s plug-in management tool to manage it. Please check it yourself if necessary.
2. Install configuration plug-in
- After installing the plug-in, write some configurations in the ~/.vimrc file
Configure the nerdtree plug-in as follows
"------------------------------------------------ ----------" " NERD Tree environment settings "------------------------------------------------ ---------" let NERDTreeWinPos = "left" nmap <F9> :NERDTreeToggle<CR>
This means using the F9 button to open and close the plug-in. The effect is no longer displayed. At this point you can customize your vim independently.
3. Give the required plug-ins, related configurations and their effects
If there are problems with some of the plug-ins I described or if you want other effects, go to Baidu yourself. Basically there are tutorials and configuration methods.
ctags and cscope are not vim plug-ins in the strict sense. To download them, we need to use the yum install ctags cscope command
-
ctags,cscope
After the installation is complete, command ctags -R to generate ctags tags, and cscope -Rbq to generate cscope tags. You can use ctrl + ] or cs find to find the function definition. Please refer to other blogs for specific usage. Remember that there is a problem. The directory generated by ctags seems to be a relative directory. Sometimes a tag is found, and an error will be reported after entering. The tag cannot be found.
Since cscope uses relative paths by default when generating the database, the above situation occurs. The solution is to manually generate a cscope.files file and specify the absolute path of the file. The cscope command will generate a symbol index file based on the file specified in cscope.files. Therefore, when generating cscope.files, all files are presented as absolute paths, which can solve the problem of files not being found when cscope jumps.find `pwd` -name *.c -o -name *.h -o -name *.cc> cscope.files
Regenerate the cscope database:
cscope -bkq -i cscope.files
ctags -RThe configuration is given as follows. You can use the shortcut key ctrl + leader key and then press 1, 2, 3, 4, 5, 6 to use the corresponding functions of cscope.
if has("cscope") "set csprg=/usr/local/bin/cscope set csto=0 set cst set nocsverb set cspc=3 "Specify how many levels of file paths to display in the search results. The default value 0 means displaying the full path, 1 means only displaying the file name." if filereadable("cscope.out") cs add $PWD/cscope.out $PWD "cs add cscope.out else" subdirectory opens and searches upward let cscope_file=findfile("cscope.out", ".;") let cscope_pre=matchstr(cscope_file, ".*/") if !empty(cscope_file) & amp; & amp; filereadable(cscope_file) exe "cs add" cscope_file cscope_pre endif endif set csverb endif nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap <C-\>i :cs find i <C-R>=expand("<cfile>")<CR><CR> nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
-
NERDtree
The above and display configuration, here is an enhanced configuration. The effect after configuration is that you can jump to other files by pressing F9 to refresh the directory structure and display the directory structure of the file you are checking. PS: Comment out the f9 configured above. .
nmap <F9> :call NERDTreeToggleAndRefresh()<CR> function NERDTreeToggleAndRefresh() :NERDTreeToggle if ! g:NERDTree.IsOpen() :NERDTreeFind endif endfunction
- TagList SrcEXl
Give the configuration directly
"------------------------------------------------ ----------" " Tap List environment settings "------------------------------------------------ --------" filetype on nmap <F7> :TlistToggle<CR> let Tlist_Ctags_Cmd = "/usr/bin/ctags" let Tlist_Inc_Winwidth = 0 let Tlist_Exit_OnlyWindow = 0 let Tlist_Auto_Open = 0 let Tlist_Use_Right_Window = 1 "------------------------------------------------ --------" " Source Explorer environment settings "------------------------------------------------ --------" nmap <F8> :SrcExplToggle<CR> nmap <C-J> <C-W>h nmap <C-K> <C-W>j nmap <C-I> <C-W>k nmap <C-L> <C-W>l let g:SrcExpl_WinHeight = 8 let g:SrcExpl_refreshTime = 100 let g:SrcExpl_jumpKey = "<ENTER>" let g:SrcExpl_gobackKey = "<SPACE>" let g:SrcExpl_isUpdateTags = 0
- Bracket auto-completion function
"Bracket completion inoremap ( ()<ESC>i inoremap [ []<ESC>i inoremap {<!-- --> {<!-- --><CR>}<Esc>O inoremap < <><ESC>i autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR> inoremap ) <c-r>=ClosePair(')')<CR> inoremap } <c-r>=CloseBracket()<CR> inoremap " <c-r>=QuoteDelim('"')<CR> inoremap ' <c-r>=QuoteDelim("'")<CR> function ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endf function CloseBracket() if match(getline(line('.') + 1), '\s*}') < 0 return "\<CR>}" else return "\<Esc>j0f}a" endif endf function QuoteDelim(char) let line = getline('.') let col = col('.') if line[col - 2] == "" return a:char elseif line[col - 1] == a:char return "\<Right>" else return a:char.a:char."\<Esc>i" endif endf
-lightline
To download the lightline plug-in
set laststatus=2 set noshowmode let g:lightline = {<!-- --> 'colorscheme': 'PaperColor_dark', 'component_function': {<!-- --> \ 'mode': 'LightlineMode', \}, \} let g:lightline = {<!-- --> \ 'active': {<!-- --> \ 'left': [ [ 'mode', 'paste' ], [ 'readonly', 'absolutepath', 'modified' ] ], \} \} function!LightlineMode() return expand('%:t') =~# '^__Tagbar__' ? 'Tagbar': \expand('%:t') ==# 'ControlP' ? 'CtrlP' : \ & amp;filetype ==# 'unite' ? 'Unite' : \ & amp;filetype ==# 'vimfiler' ? 'VimFiler' : \ & amp;filetype ==# 'vimshell' ? 'VimShell' : \lightline#mode() endfunction
-autocomplpop, omnicppcomplete realize automatic grammar completion
"------------------------------------------------ --------" " Grammar completion settings "------------------------------------------------ --------" map <C-F12> :!ctags -R --c + + -kinds= + p --fields= + iaS --extra= + q .<CR> "OmniCppComplete let OmniCpp_NamespaceSearch = 1 let OmniCpp_GlobalScopeSearch = 1 letOmniCpp_ShowAccess = 1 let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters let OmniCpp_MayCompleteDot = 1 " autocomplete after . let OmniCpp_MayCompleteArrow = 1 " autocomplete " automatically starts with vim let g:indent_guides_enable_on_vim_startup=1 " Visually display indentation starting from the second level let g:indent_guides_start_level=2 "Color block width let g:indent_guides_guide_size=1 " Shortcut key i turns on/off indent visualization :nmap <silent> <Leader>i <Plug>IndentGuidesToggleafter -> let OmniCpp_MayCompleteScope = 1 " autocomplete after :: let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] " automatically open and close the popup menu / preview window au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif set completeopt=menuone,menu,longest,preview
Vim’s buffer tab windows knowledge points can be consulted by yourself. I will give you a plug-in and configure it to realize the operation of vim files opened before and after F2 and F3 switching.
- minibufexpl.vim
Download the github address yourself. It’s too long.
Link: https://github.com/fholgado/minibufexpl.vim/blob/master/plugin/minibufexpl.vim
The file I gave you is placed under ~.vim/plugin
Then go to .vimrc and configure the following to use it
set hidden map <F2> :bp<CR> map <F3> :bn<CR>
Now that vim’s code viewing function has been implemented, you need to be more familiar with the ctags and cscope commands.
3. GDB debug ceph and integrate it into vim
pending upgrade…