Ben Fritz suggested using the matchadd()/matchdelete() functions
than what I did, but I solved the problem another way before seeing his comments.
work exactly once and then not again. There is some strange
interaction happening with the highlight group that I have not yet been able to identify.syntax highlighting on/off:
" L9 Key [Toggle syntax hilight on/off]
nnoremap <Esc>[55~ :if exists("g:syntax_on") <Bar>
\ syntax off <Bar>
\ endif <Bar>
\ else <Bar>
\ syntax enable <Bar>
\ endif<CR><CR>
the highlighting group.
" L9 (Shifted) [Toggle nonascii highlighting]
nnoremap <Esc>[55;2~ :source /u/jeff/lib/vi/vimrc.nonascii<CR>
Where the vimrc.nonascii file contains:nnoremap <Esc>[55;2~ :source /u/jeff/lib/vi/vimrc.nonascii<CR>
if (nonascii == "on")
syntax clear NONASCII
let nonascii = "off"
else
syntax match NONASCII "[^\x00-\x7F]"
highlight NONASCII ctermbg=13
let nonascii = "on"
endif
left the "nonascii" variable in the wrong state.
" L9 Key [Toggle syntax hilight on/off]
nnoremap <Esc>[55~ :if exists("g:syntax_on") <Bar>
\ syntax off <Bar>
\ if (nonascii == "on") <Bar>
\ let nonascii = "off" <Bar>
\ :source /u/jeff/lib/vi/vimrc.nonascii <Bar>
\ endif <Bar>
\ else <Bar>
\ syntax enable <Bar>
\ if (nonascii == "on") <Bar>
\ let nonascii = "off" <Bar>
\ :source /u/jeff/lib/vi/vimrc.nonascii <Bar>
\ endif <Bar>
\ endif<CR><CR>
\ syntax off <Bar>
\ if (nonascii == "on") <Bar>
\ let nonascii = "off" <Bar>
\ :source /u/jeff/lib/vi/vimrc.nonascii <Bar>
\ endif <Bar>
\ else <Bar>
\ syntax enable <Bar>
\ if (nonascii == "on") <Bar>
\ let nonascii = "off" <Bar>
\ :source /u/jeff/lib/vi/vimrc.nonascii <Bar>
\ endif <Bar>
\ endif<CR><CR>
Why two <CR> are required here is another minor mystery. It's
probably because of the :source command which gobbles one
<CR> leaving the second for the overall command. However,
adding a <CR> to the end of the :source lines and removing one
from the end does not work!
I hope someone finds this instructive. Continue the discussion if
there are more insights as to what is going on with these perceived
glitches I was experiencing.
Much thanks to Ben and Tony for their very helpful feedback. I
learned a few things and got pushed in the right direction.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment