f



[vim] Function to find out highlighting style + region local key bindings?

Hi,

Does somebody know an answer to these 3 question/problems?

1. Is there a function in Vim 6.2 for finding out in which style the
character under the cursor is being highlighted? I.e. is it possible to
define a function that behaves differently depending on which syntactic
element the cursor is on?

2. Is it possible to restrict certain key binding to certain regions
only? I.e. is it possible to invoke different commands with the same key
press depending on the cursor's location?

3. Is it possible to shadow a keybinding and to invoke the command that
would have been called if a certain command wasn't bound to a certain
key sequence? Let's say command CmdA is bound to key A. Then CmdB is
bound to the same key. Now, CmdB should first check if a certain
condition is met and then do something or, if not, call CmdA.

Cheers,
Thomas.
0
Thomas
12/2/2003 12:36:19 PM
comp.editors 4871 articles. 0 followers. Post Follow

3 Replies
397 Views

Similar Articles

[PageSpeed] 11

Thomas Link scripsit:
> Hi,
> Does somebody know an answer to these 3 question/problems?
> 1. Is there a function in Vim 6.2 for finding out in which style the
> character under the cursor is being highlighted? I.e. is it possible to
> define a function that behaves differently depending on which syntactic
> element the cursor is on?

:echo  synIDattr(synID(line('.'),col('.'),0),"name")

> 2. Is it possible to restrict certain key binding to certain regions
> only? I.e. is it possible to invoke different commands with the same key
> press depending on the cursor's location?

Check tip #102 at vim-online.

> 3. Is it possible to shadow a keybinding and to invoke the command that
> would have been called if a certain command wasn't bound to a certain
> key sequence? Let's say command CmdA is bound to key A. Then CmdB is
> bound to the same key. Now, CmdB should first check if a certain
> condition is met and then do something or, if not, call CmdA.

Yes.

m.
-- 
LaTeX + Vim = http://vim-latex.sourceforge.net/
Learn Touch Typing with Vim? Oui. Ja. Yes. Tak:
    http://vim.sourceforge.net/script.php?script_id=461
vim.pl - http://skawina.eu.org/mikolaj
0
Mikolaj
12/2/2003 9:40:59 PM
Mikolaj Machowski <mikmach@wp.pl> wrote in 
news:slrnbspkbs.uj0.mikmach@blacher.nos:

>:echo  synIDattr(synID(line('.'),col('.'),0),"name")

> Check tip #102 at vim-online.

Thanks a lot,
Thomas.
0
Thomas
12/3/2003 9:15:08 AM
Thomas Link <samul@web.de> wrote in message news:<3ullpv8kho.fsf@web.de>...
> Hi,
> 
> Does somebody know an answer to these 3 question/problems?
> 
> 1. Is there a function in Vim 6.2 for finding out in which style the
> character under the cursor is being highlighted? I.e. is it possible to
> define a function that behaves differently depending on which syntactic
> element the cursor is on?
> 
Yes. :help synID() and :help synIDattr()

> 2. Is it possible to restrict certain key binding to certain regions
> only? I.e. is it possible to invoke different commands with the same key
> press depending on the cursor's location?
> 
Yes. :help line() and :help col()
0
stonnedsnake
12/3/2003 12:09:59 PM
Reply: