m (Auto highlight word under cursor (when reading new code) moved to Auto highlight current word when idle: Page moved by JohnBot to improve title) |
(Change to TipImported template + severe manual clean) |
||
Line 1: | Line 1: | ||
{{review}} |
{{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=572 |
|id=572 |
||
+ | |previous=571 |
||
− | |title=auto highlight word under cursor (when reading new code) |
||
+ | |next=573 |
||
− | |created=September 30, 2003 |
+ | |created=September 30, 2003 |
|complexity=basic |
|complexity=basic |
||
− | |author=mosh |
+ | |author=mosh |
|version=6.0 |
|version=6.0 |
||
|rating=23/10 |
|rating=23/10 |
||
− | |text= |
||
}} |
}} |
||
<pre> |
<pre> |
||
− | " Highlight all instances of word under cursor, when idle. |
+ | " Highlight all instances of word under cursor, when idle. |
− | " Useful when studying strange source code. |
+ | " Useful when studying strange source code. |
− | " Turn on/off with z/ (or key of your choice) |
+ | " Turn on/off with z/ (or key of your choice) |
⚫ | |||
+ | function! Auto_Highlight_Cword() |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | + | function! Auto_Highlight_Toggle() |
|
⚫ | |||
⚫ | |||
⚫ | |||
− | :endfunction |
||
⚫ | |||
− | |||
+ | else |
||
− | function! Mosh_Auto_Highlight_Toggle() |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | endif |
||
− | :else |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | :endif |
||
⚫ | |||
− | |||
− | |||
− | " There is cold meat i' the cave; we'll browse on that, |
||
− | " -- GUIDERIUS, in Cymbeline by Shakespeare. |
||
</pre> |
</pre> |
||
⚫ | |||
− | No occupation; all men idle, all; |
||
⚫ | |||
− | -- GONZALO, Tempest by ShakesPear. |
||
− | |||
− | http://www.cs.albany.edu/~mosh - Mohsin. |
||
− | |||
⚫ | |||
⚫ | |||
− | |||
− | Salman Halim |
||
− | , October 1, 2003 6:42 |
||
− | <!-- parsed by vimtips.py in 0.477204 seconds--> |
||
+ | ---- |
||
[[Category:Syntax]] |
[[Category:Syntax]] |
Revision as of 07:29, 4 November 2007
Tip 572 Printable Monobook Previous Next
created September 30, 2003 · complexity basic · author mosh · version 6.0
" Highlight all instances of word under cursor, when idle. " Useful when studying strange source code. " Turn on/off with z/ (or key of your choice) map z/ :call Auto_Highlight_Toggle()<CR> function! Auto_Highlight_Cword() exe "let @/='\\<".expand("<cword>")."\\>'" endfunction function! Auto_Highlight_Toggle() if exists("#CursorHold#*") au! CursorHold * let @/='' else set hlsearch set updatetime=500 au! CursorHold * nested call Auto_Highlight_Cword() endif endfunction
Comments
I would suggest placing the CursorHold event inside an autocommand group (augroup); the way this is right now would clobber my other CursorHold autocommands.