Skip to content

Instantly share code, notes, and snippets.

@hanxi
Created January 25, 2019 02:01
Show Gist options
  • Select an option

  • Save hanxi/451321371ff104e310efc57737ee864f to your computer and use it in GitHub Desktop.

Select an option

Save hanxi/451321371ff104e310efc57737ee864f to your computer and use it in GitHub Desktop.
function! s:gen_tags_find(cmd, keyword) abort
" Mark this position
execute "normal! mY"
" Close any open quickfix windows
cclose
" Clear existing quickfix list
cal setqflist([])
let l:cur_buf=@%
let l:cmd = 'cs find ' . a:cmd . ' ' . a:keyword
silent! keepjumps execute l:cmd
if len(getqflist()) > 1
" If the buffer that cscope jumped to is not same as current file, close the buffer
if l:cur_buf != @%
" Go back to where the command was issued
execute "normal! `Y"
" delete previous buffer.
bdelete #
endif
copen
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment