VIM: help writing a function... - Editors

This is a discussion on VIM: help writing a function... - Editors ; Hi guys, I'm a total Vim scripting newbie, and I would like to make a function that on keypress "escapes" the cursor from a closed pair of parentheses or quotes. For example, this is the scenario ("|" marks the cursor): ...

+ Reply to Thread
Results 1 to 2 of 2

VIM: help writing a function...

  1. Default VIM: help writing a function...

    Hi guys, I'm a total Vim scripting newbie, and I would like to make a
    function that on keypress "escapes" the cursor from a closed pair of
    parentheses or quotes. For example, this is the scenario ("|" marks the
    cursor):

    def function(|):

    After pressing some key combination, I wan't it to be like this:

    def function()|:

    Also, it should work for nested pairs, so for example, it should be able
    to repeatedly escape the cursor from this situation (listed below are the
    steps it takes):

    hasmap[funtion('argument|')]
    hasmap[funtion('argument'|)]
    hasmap[funtion('argument')|]
    hasmap[funtion('argument')]|

    I'm not looking for the complete function, just some ideas and Vim
    functions I should use so I know what to Google for .

    Thanks a lot...


    --
    _______ Karlo Lozovina - Mosor
    | | |.-----.-----. web: http://www.mosor.net || ICQ#: 10667163
    | || _ | _ | Parce mihi domine quia Dalmata sum.
    |__|_|__||_____|_____|

  2. Default Re: VIM: help writing a function...

    On 30/05/08 20:28, Karlo Lozovina wrote:
    > Hi guys, I'm a total Vim scripting newbie, and I would like to make a
    > function that on keypress "escapes" the cursor from a closed pair of
    > parentheses or quotes. For example, this is the scenario ("|" marks the
    > cursor):
    >
    > def function(|):
    >
    > After pressing some key combination, I wan't it to be like this:
    >
    > def function()|:
    >
    > Also, it should work for nested pairs, so for example, it should be able
    > to repeatedly escape the cursor from this situation (listed below are the
    > steps it takes):
    >
    > hasmap[funtion('argument|')]
    > hasmap[funtion('argument'|)]
    > hasmap[funtion('argument')|]
    > hasmap[funtion('argument')]|
    >
    > I'm not looking for the complete function, just some ideas and Vim
    > functions I should use so I know what to Google for .
    >
    > Thanks a lot...
    >
    >


    The way you show it, the right-arrow key would do it, but I suppose
    that's not what you mean. I guess a few additional counterexamples would
    help.

    About the quotes, remember that quote characters are not always paired,
    as in
    "It's an apostrophe but not a quote"
    or
    " a Vim command rarely contains a second quote

    To find help about Vim, don't use Google, use Vim's own help system,
    and, about how to search it, see

    :help :help
    :help {subject}
    where {subject} is brace, s, u, b, j, e, c, t, brace
    :help :helpgrep

    Best regards,
    Tony.
    --
    "I love Saturday morning cartoons, what classic humour! This is what
    entertainment is all about ... Idiots, explosives and falling anvils."
    -- Calvin and Hobbes, Bill Watterson

+ Reply to Thread