diff options
| author | Max Christian Pohle | 2022-12-18 20:29:55 +0100 |
|---|---|---|
| committer | Max Christian Pohle | 2022-12-18 20:56:01 +0100 |
| commit | 07797b39851da045aa1bfd0289de0858a1377c48 (patch) | |
| tree | 4ca5d2b26d2ca9d01fc052fce5a26f88364a53d0 /CursorHold-example.vim | |
| parent | 1086af63639d2a108f39ae077e0e201dddf4f523 (diff) | |
| download | vim-07797b39851da045aa1bfd0289de0858a1377c48.tar.bz2 vim-07797b39851da045aa1bfd0289de0858a1377c48.zip | |
Switched to nvim and neovide
Diffstat (limited to 'CursorHold-example.vim')
| -rw-r--r-- | CursorHold-example.vim | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/CursorHold-example.vim b/CursorHold-example.vim deleted file mode 100644 index ae55396..0000000 --- a/CursorHold-example.vim +++ /dev/null | |||
| @@ -1,37 +0,0 @@ | |||
| 1 | au! CursorHold *.[ch] nested call PreviewWord() | ||
| 2 | func PreviewWord() | ||
| 3 | if &previewwindow " don't do this in the preview window | ||
| 4 | return | ||
| 5 | endif | ||
| 6 | let w = expand("<cword>") " get the word under cursor | ||
| 7 | if w =~ '\a' " if the word contains a letter | ||
| 8 | |||
| 9 | " Delete any existing highlight before showing another tag | ||
| 10 | silent! wincmd P " jump to preview window | ||
| 11 | if &previewwindow " if we really get there... | ||
| 12 | match none " delete existing highlight | ||
| 13 | wincmd p " back to old window | ||
| 14 | endif | ||
| 15 | |||
| 16 | " Try displaying a matching tag for the word under the cursor | ||
| 17 | try | ||
| 18 | exe "ptag " . w | ||
| 19 | catch | ||
| 20 | return | ||
| 21 | endtry | ||
| 22 | |||
| 23 | silent! wincmd P " jump to preview window | ||
| 24 | if &previewwindow " if we really get there... | ||
| 25 | if has("folding") | ||
| 26 | silent! .foldopen " don't want a closed fold | ||
| 27 | endif | ||
| 28 | call search("$", "b") " to end of previous line | ||
| 29 | let w = substitute(w, '\\', '\\\\', "") | ||
| 30 | call search('\<\V' . w . '\>') " position cursor on match | ||
| 31 | " Add a match highlight to the word at this position | ||
| 32 | hi previewWord term=bold ctermbg=green guibg=green | ||
| 33 | exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"' | ||
| 34 | wincmd p " back to old window | ||
| 35 | endif | ||
| 36 | endif | ||
| 37 | endfun | ||
