On 12/6/06, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
I think it is doable, but it's not my province really. Some other Vim old-timers are much more versed than I in the creation of that kind of "self-undoing" mappings.
It can probably be simplified by mapping <CR> in command mode and check if getcmdtype() is '/' or '?' and, if so, call :match as appropriate. However, there's no good way of doing this type of highlighting while in 'incsearch' mode (i.e., while typing the pattern). Anyway, here's something I cooked up for you 'incsearch' users that actually thought this was sort of a neat idea, i.e., being able to quickly toggle between the word anywhere in the buffer, the complete word, and the case insensitive word. It definitely needs work to deal with anything but trivial patterns, e.g., only wrap the word under the cursor, but you probably only want to do this for simple, word-type patterns. cmap <C-I> <C-\>e<SID>toggle_word_style()<CR> let s:word_types = [ \ [ '^\\<\|\\>$', "", 'g', '\c', "" ], \ [ '^\\c', "", "", "", "" ], \ [ '^', "", "", '\<', '\>' ] \ ] function! s:toggle_word_style() let line = getcmdline() let type = getcmdtype() if type != '/' && type != '?' return line endif for word_type in s:word_types if line =~ word_type[0] let line = word_type[3] . \ substitute(line, word_type[0], word_type[1], word_type[2]) . \ word_type[4] call setcmdpos(len(line) + 1) return line endif endfor return line endfunction Actually sort of neat, although it's not what Mohsin wants. nikolai