On Wed, 7 Mar 2012, [email protected] wrote:
Hi,
is there a way to print out that informations which is responnsible
for giving the symbol under the cursor its appearance in a way which
enables me to directly find the according line in the current
colorscheme to modify that line to my needs?
There are a bunch of things that make this less than ideal: One of the
reasons I don't think it exists is that the current colorscheme doesn't
have to be defined in one place. Some highlighting groups can be set up
in .vimrc or other plugins. And many items are colored the way they're
colored due to 'linked' highlighting. Vim doesn't keep track of where a
given highlight group was linked, so the ultimate "This is what caused
this item to appear in this color" information isn't even necessarily
available.
Here's a (tested) rough idea of how you might do something like what I
think you're looking for. To use it, run the EditColor command. It
will populate the error list with a list of places the current
highlighting group could have been defined.
==> ~/.vim/plugin/edit-current-color.vim <==
" Need the synstack() function, added in 7.1.something
if !exists('*synstack')
finish
endif
fun! s:CurrentColor()
let stack = synstack(line('.'), col('.'))
let name = len(stack) ? synIDattr(stack[-1], 'name') : 'Normal'
return synIDattr(synIDtrans(hlID(name)), 'name')
endfun
fun! s:CurrentSchemeFiles()
let name = exists('g:colors_name') ? g:colors_name : 'default'
return split(globpath(&rtp, 'colors/'.g:colors_name.'.vim'),"\n")
endfun
com! EditColor exe 'vimgrep /hi\%[ghlight]\ \+\%(link\ \|def\
\)*\<'.s:CurrentColor().'\>/
'.join(map(s:CurrentSchemeFiles(),'fnameescape(v:val)'),' ')
============================================
Just another example of why this is harder than it might seem: One
thing this will never pick up is that the command that created the
highlighting group could have been generated. E.g.:
for i in range(5)
exe 'hi Foo'.i 'ctermfg='.(i+200)
endfor
--
Best,
Ben
--
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