From 8f350dc3287ae78643fe2711065254e7042b9c8a Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Tue, 10 Jul 2018 23:02:09 +0200 Subject: Added preview window function from the help improved man pager integration improved fonts for gvim --- CursorHold-example.vim | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 CursorHold-example.vim (limited to 'CursorHold-example.vim') diff --git a/CursorHold-example.vim b/CursorHold-example.vim new file mode 100644 index 0000000..ae55396 --- /dev/null +++ b/CursorHold-example.vim @@ -0,0 +1,37 @@ +au! CursorHold *.[ch] nested call PreviewWord() +func PreviewWord() + if &previewwindow " don't do this in the preview window + return + endif + let w = expand("") " get the word under cursor + if w =~ '\a' " if the word contains a letter + + " Delete any existing highlight before showing another tag + silent! wincmd P " jump to preview window + if &previewwindow " if we really get there... + match none " delete existing highlight + wincmd p " back to old window + endif + + " Try displaying a matching tag for the word under the cursor + try + exe "ptag " . w + catch + return + endtry + + silent! wincmd P " jump to preview window + if &previewwindow " if we really get there... + if has("folding") + silent! .foldopen " don't want a closed fold + endif + call search("$", "b") " to end of previous line + let w = substitute(w, '\\', '\\\\', "") + call search('\<\V' . w . '\>') " position cursor on match + " Add a match highlight to the word at this position + hi previewWord term=bold ctermbg=green guibg=green + exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"' + wincmd p " back to old window + endif + endif +endfun -- cgit v1.2.3