On 11/04/09 04:48, Ben Kovitz wrote:
>
> I'm writing some commands to make it so you can edit Scheme in vim at
> the level of s-expressions.  Is there a way to find out, inside a
> function, what type of syntactic item the cursor is in?
>
> For example, vim "knows" if it's in a string or comment.  I'd like the
> keys to behave differently depending on what kind of thing the cursor
> is on.  For example, when inside a string literal, there's no need to
> automatically insert a right parenthesis when you type a left
> parenthesis.
>
> Ben Kovitz

I know of several totally different ways to solve that kind of problem:

I. As used by the "matchparen" plugin: examine the character under the 
cursor, maybe some more around that, and behave differently depending on 
what is found.

II. Most versatile but limited to a given filetype: examine the syntax 
groups under the cursor by means of the functions

        syinID()
        synIDattr()
        synIDtrans()

(qq.v.)

III. As used by the matchit plugin: I don't know how it does it (you may 
go and look), but matchit doesn't match { with } if one of them is 
inside a comment and the other not.


Best regards,
Tony.
-- 
"The Lord gave us farmers two strong hands so we could grab as much as
we could with both of them."
                -- Joseph Heller, "Catch-22"

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to