diff options
| author | Max Christian Pohle | 2018-07-10 23:02:09 +0200 |
|---|---|---|
| committer | Max Christian Pohle | 2018-07-10 23:02:09 +0200 |
| commit | 8f350dc3287ae78643fe2711065254e7042b9c8a (patch) | |
| tree | 9a2fdc50fa9ec3d693737141c0c50cc3c6f629a8 /CursorHold-example.vim | |
| parent | 15fad7fd1701a16dfd1bf90854606a59473be09b (diff) | |
| download | vim-karlmarks-8f350dc3287ae78643fe2711065254e7042b9c8a.tar.bz2 vim-karlmarks-8f350dc3287ae78643fe2711065254e7042b9c8a.zip | |
Added preview window function from the help
improved man pager integration
improved fonts for gvim
Diffstat (limited to 'CursorHold-example.vim')
| -rw-r--r-- | CursorHold-example.vim | 37 |
1 files changed, 37 insertions, 0 deletions
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 @@ | |||
| 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 | ||
