On Mon, February 8, 2010 10:24 am, Eric Smith wrote:
> Christian Brabandt said:
>> ,----
>> | nmap tr :exe "call
>> matchadd('WarningMsg','\\%".line('.').'l'.expand("<cword>") . "')"<CR>
>> | nmap tq ma[S1z=tr|
>> `----
>>
> This mapping is supercool. Useful everytime I type.
>
> What I want is to have a command that can cancel the highlighting
> on all the words currently highlighted according to the above matchadd.
> This I will do when I have checked that all those words are spelt ok and
> then
> it makes it easier to work and to spot the new errors.
>
> Once again thanks for this really useful tool!
The simplest solution would be to clear all matches:
nmap <F7> :call clearmatches()<CR>
but this also affects matches, that have not been set by this mapping.
If you don't want that, the mapping has to be changed to something like
this:
nmap tr :if !exists("b:a") <bar> let b:a=[] <bar> endif <bar>:call
add(b:a,matchadd('WarningMsg','\%'.line('.').'l'.expand("<cword>")))<CR>
nmap tq ma[S1z=tr|
nmap <F7> :if exists("b:a")<bar>:for val in b:a<bar>:silent! call
matchdelete(val)<bar>:endfor<bar>:let b:a=[]<bar>:endif<cr>
(each nmap command is 1 line).
This should take care of it and also handle the obvious errors I could
imagine, though I only tested it barely.
regards,
Christian
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php