Add mapping to rename include guards in c/cpp
This commit is contained in:
parent
25c18763bc
commit
c80ddd3617
@ -54,3 +54,17 @@ function! do#cursor_highlight_groups()
|
||||
let l:lo = synIDattr(synIDtrans(synID(line('.'),col('.'),1)),'name')
|
||||
echo 'hi<'.l:hi.'> trans<'.l:trans.'> lo<'.l:lo.'>'
|
||||
endfunction
|
||||
|
||||
" Rename C/C++ include guard
|
||||
function! do#rename_include_guard(old)
|
||||
" Prompt for new guard name
|
||||
let l:new = input('Rename include guard: ', a:old)
|
||||
" Set a mark to jump back to
|
||||
normal mr
|
||||
" Replace the old guard name with the new one
|
||||
exec '%s/\(#ifndef\|#define\|#endif\s\+\/\/\)\s\+\zs'.a:old.'/'.l:new.'/g'
|
||||
" Stop highlighting search results
|
||||
nohlsearch
|
||||
" Jump back to the set mark
|
||||
normal 'r
|
||||
endfunction
|
||||
|
@ -91,3 +91,6 @@ nnoremap <leader><CR> :ToggleCheckbox<CR>
|
||||
|
||||
" Show highlight groups under the cursor
|
||||
nnoremap <leader>hi :CursorHighlightGroups<CR>
|
||||
|
||||
" Rename C/C++ include guard
|
||||
nnoremap <leader>rg :call do#rename_include_guard(expand('<cword>'))<cr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user