Peng Yu [2008-10-18 16:27 -0700]:
> '_' does mean something in math mode. Is there a way to make vim
> interpret it based on the environment? Syntax highlight can be made
> context dependent, I think that it is also possible to make the
> interpretation of '_' context dependent, right?
If I understood your question correctly, it is possible. We can at least
detect the "context" by the information the syntax highlighting gives
us. The idea is to check what syntax highlight item the cursor is on and
run commands automatically based on that information. Here's my untested
prototype code:
" Autocommad to run every time the cursor is moved
augroup MyDetectContextGroup
autocmd! * <buffer>
autocmd! CursorMoved,CursorMovedI <buffer> call s:DetectContext()
augroup END
" This function checks what syntax item the cursor is on
" and acts accordingly.
function s:DetectContext()
let syntax_name = synIDattr(synID(line('.'),col('.',1),'name')
if syntax_name == 'name of the syntax item here'
setlocal iskeyword=whatever
else
setlocal iskeyword=somethingelse
endif
" When finding appropriate syntax item name(s) it's
" useful to print the name in the echo area.
" After that the following line can be removed:
echo syntax_name
endfunction
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---