Loading ...
Sorry, an error occurred while loading the content.
 

Re: Mapping of keysequences...

Expand Messages
  • Mikolaj Machowski
    ... If you want to print it in the buffer it should be:: noremap b iecho works If you want to echo it in command line:: noremap b :echo
    Message 1 of 15 , Oct 1, 2006
      Dnia niedziela, 1 października 2006 14:54, Meino Christian Cramer napisał:
      > Hi,
      >
      > is it possible to map the sequence of
      >
      > <C-C><C-F>b
      >
      > to anything (and how?)?
      >
      > I tried as a first brute-force experiment
      >
      > noremap <C-C><C-F>b echo "works"

      If you want to print it in the buffer it should be::

      noremap <C-C><C-F>b iecho "works"

      If you want to echo it in command line::

      noremap <C-C><C-F>b :echo "works"

      Normal mode mappings begin in Normal mode, not Insert or Command-Line.

      m.
    • Meino Christian Cramer
      From: A.J.Mechelynck Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 15:09:17 +0200 ... Hi Tony, ah...oh! Yes!
      Message 2 of 15 , Oct 1, 2006
        From: "A.J.Mechelynck" <antoine.mechelynck@...>
        Subject: Re: Mapping of keysequences...
        Date: Sun, 01 Oct 2006 15:09:17 +0200

        > Meino Christian Cramer wrote:
        > > Hi,
        > >
        > > is it possible to map the sequence of
        > >
        > > <C-C><C-F>b
        > >
        > > to anything (and how?)?
        > >
        > > I tried as a first brute-force experiment
        > >
        > > noremap <C-C><C-F>b echo "works"
        > >
        > > But it does not "works"... :)
        > >
        > > Any chance to do such a trick?
        > >
        > > Thanks a lot for any help !
        > > keep hacking!
        > > mcc
        > >
        >
        > Mapping Ctrl-C works only when Vim is waiting for input (see "help
        > map_CTRL-C"); however, your brute-force method is in error. You should have tried
        >
        > :noremap <C-C><C-F>b :echo "works"<CR>
        >
        > with a colon to start an Ex-command and a carriage-return to end it.
        >
        >
        > Best regards,
        > Tony.
        >
        Hi Tony,

        ah...oh! Yes! I should had know this...
        With the additional ":" and <CR> it works nicely!

        *THANKS* :O)

        Keep hacking!
        mcc
      • Meino Christian Cramer
        From: Mikolaj Machowski Subject: Re: Mapping of keysequences... Date: Sun, 1 Oct 2006 15:09:56 +0200 ... Hmmmppff....I got a problem here...
        Message 3 of 15 , Oct 1, 2006
          From: Mikolaj Machowski <mikmach@...>
          Subject: Re: Mapping of keysequences...
          Date: Sun, 1 Oct 2006 15:09:56 +0200

          > Dnia niedziela, 1 października 2006 14:54, Meino Christian Cramer napisał:
          > > Hi,
          > >
          > > is it possible to map the sequence of
          > >
          > > <C-C><C-F>b
          > >
          > > to anything (and how?)?
          > >
          > > I tried as a first brute-force experiment
          > >
          > > noremap <C-C><C-F>b echo "works"
          >
          > If you want to print it in the buffer it should be::
          >
          > noremap <C-C><C-F>b iecho "works"
          >
          > If you want to echo it in command line::
          >
          > noremap <C-C><C-F>b :echo "works"
          >
          > Normal mode mappings begin in Normal mode, not Insert or Command-Line.
          >
          > m.
          >

          Hmmmppff....I got a problem here...

          What I want is to insert the string "{\bf }" (TeX!) in a buffer. It
          should work in insert mode. I want to press <C-C><C-F>b in insert mode
          and it should print "{\bf }" at the place where currently the cursor
          is.

          I did

          inoremap <C-C><C-F>b iecho "{\bf }"

          . And guess what happens? It prints "iecho {\bf }" into the buffer!
          When using 'noremap' instead of 'inoremap' nothing happens.

          :he iecho

          gives me simply nothing. Is there any needle in the haystack I can
          search for?

          Keep hacking!
          mcc
        • A.J.Mechelynck
          ... If you are already in Insert mode, the right-hand side of the mapping is used as if you had typed it. To insert left-brace backslash bee eff space
          Message 4 of 15 , Oct 1, 2006
            Meino Christian Cramer wrote:
            > From: Mikolaj Machowski <mikmach@...>
            > Subject: Re: Mapping of keysequences...
            > Date: Sun, 1 Oct 2006 15:09:56 +0200
            >
            >> Dnia niedziela, 1 października 2006 14:54, Meino Christian Cramer napisał:
            >>> Hi,
            >>>
            >>> is it possible to map the sequence of
            >>>
            >>> <C-C><C-F>b
            >>>
            >>> to anything (and how?)?
            >>>
            >>> I tried as a first brute-force experiment
            >>>
            >>> noremap <C-C><C-F>b echo "works"
            >> If you want to print it in the buffer it should be::
            >>
            >> noremap <C-C><C-F>b iecho "works"
            >>
            >> If you want to echo it in command line::
            >>
            >> noremap <C-C><C-F>b :echo "works"
            >>
            >> Normal mode mappings begin in Normal mode, not Insert or Command-Line.
            >>
            >> m.
            >>
            >
            > Hmmmppff....I got a problem here...
            >
            > What I want is to insert the string "{\bf }" (TeX!) in a buffer. It
            > should work in insert mode. I want to press <C-C><C-F>b in insert mode
            > and it should print "{\bf }" at the place where currently the cursor
            > is.
            >
            > I did
            >
            > inoremap <C-C><C-F>b iecho "{\bf }"
            >
            > . And guess what happens? It prints "iecho {\bf }" into the buffer!
            > When using 'noremap' instead of 'inoremap' nothing happens.
            >
            > :he iecho
            >
            > gives me simply nothing. Is there any needle in the haystack I can
            > search for?
            >
            > Keep hacking!
            > mcc
            >
            >

            If you are already in Insert mode, the right-hand side of the mapping is used
            as if you had typed it. To insert left-brace backslash bee eff space
            right-brace, use

            :inoremap <C-C><C-F>b {\bf }

            To do the same from Normal mode, use

            :noremap <C-D><C-F>b i{\bf }<Esc>

            with i to enter Insert mode and <Esc> to leave it.


            Best regards,
            Tony.
          • Meino Christian Cramer
            From: A.J.Mechelynck Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 18:40:47 +0200 ... Hi Tony ! nice to read
            Message 5 of 15 , Oct 1, 2006
              From: "A.J.Mechelynck" <antoine.mechelynck@...>
              Subject: Re: Mapping of keysequences...
              Date: Sun, 01 Oct 2006 18:40:47 +0200

              > Meino Christian Cramer wrote:
              > > From: Mikolaj Machowski <mikmach@...>
              > > Subject: Re: Mapping of keysequences...
              > > Date: Sun, 1 Oct 2006 15:09:56 +0200
              > >
              > >> Dnia niedziela, 1 października 2006 14:54, Meino Christian Cramer napisał:
              > >>> Hi,
              > >>>
              > >>> is it possible to map the sequence of
              > >>>
              > >>> <C-C><C-F>b
              > >>>
              > >>> to anything (and how?)?
              > >>>
              > >>> I tried as a first brute-force experiment
              > >>>
              > >>> noremap <C-C><C-F>b echo "works"
              > >> If you want to print it in the buffer it should be::
              > >>
              > >> noremap <C-C><C-F>b iecho "works"
              > >>
              > >> If you want to echo it in command line::
              > >>
              > >> noremap <C-C><C-F>b :echo "works"
              > >>
              > >> Normal mode mappings begin in Normal mode, not Insert or Command-Line.
              > >>
              > >> m.
              > >>
              > >
              > > Hmmmppff....I got a problem here...
              > >
              > > What I want is to insert the string "{\bf }" (TeX!) in a buffer. It
              > > should work in insert mode. I want to press <C-C><C-F>b in insert mode
              > > and it should print "{\bf }" at the place where currently the cursor
              > > is.
              > >
              > > I did
              > >
              > > inoremap <C-C><C-F>b iecho "{\bf }"
              > >
              > > . And guess what happens? It prints "iecho {\bf }" into the buffer!
              > > When using 'noremap' instead of 'inoremap' nothing happens.
              > >
              > > :he iecho
              > >
              > > gives me simply nothing. Is there any needle in the haystack I can
              > > search for?
              > >
              > > Keep hacking!
              > > mcc
              > >
              > >
              >
              > If you are already in Insert mode, the right-hand side of the mapping is used
              > as if you had typed it. To insert left-brace backslash bee eff space
              > right-brace, use
              >
              > :inoremap <C-C><C-F>b {\bf }
              >
              > To do the same from Normal mode, use
              >
              > :noremap <C-D><C-F>b i{\bf }<Esc>
              >
              > with i to enter Insert mode and <Esc> to leave it.
              >
              >
              > Best regards,
              > Tony.
              >

              Hi Tony !

              nice to read you again! And thank you very much for your
              help,help,help... :) <- BIG smiley!

              Slowly and surely I get my TeX macro working...

              What I have now is the following:

              inoremap <C-C><C-F>b {\bf #}<ESC>?#<CR>c/}<CR>
              inoremap <C-C><C-F>i {\it #}<ESC>?#<CR>c/}<CR>
              inoremap <C-C><C-F>s {\sl #}<ESC>?#<CR>c/}<CR>

              which "works". A last wish I would have is: After 'c'hanging the '#'
              to what I really want to typeset I will press <ESC> to leave
              'c'hanging and insert mode. But my cursor still is inside of the {}....

              Is it possible to let the macros recognize the pressing of '<ESC>'
              and then jump behind the '}' and may be entering 'i'nsert mode again?

              Or may be I need a completly different implementation of those macros
              for that?

              I often feel, that I am not thinking vim-y enough. ;o)

              Thanks a lot for all your help!

              Keep hacking!
              mcc
            • A.J.Mechelynck
              Meino Christian Cramer wrote: [...] ... The {rhs} (right-hand side) of a mapping is exactly the sequence of keys as you would hit them to accomplish the
              Message 6 of 15 , Oct 1, 2006
                Meino Christian Cramer wrote:
                [...]
                > Hi Tony !
                >
                > nice to read you again! And thank you very much for your
                > help,help,help... :) <- BIG smiley!
                >
                > Slowly and surely I get my TeX macro working...
                >
                > What I have now is the following:
                >
                > inoremap <C-C><C-F>b {\bf #}<ESC>?#<CR>c/}<CR>
                > inoremap <C-C><C-F>i {\it #}<ESC>?#<CR>c/}<CR>
                > inoremap <C-C><C-F>s {\sl #}<ESC>?#<CR>c/}<CR>
                >
                > which "works". A last wish I would have is: After 'c'hanging the '#'
                > to what I really want to typeset I will press <ESC> to leave
                > 'c'hanging and insert mode. But my cursor still is inside of the {}....
                >
                > Is it possible to let the macros recognize the pressing of '<ESC>'
                > and then jump behind the '}' and may be entering 'i'nsert mode again?
                >
                > Or may be I need a completly different implementation of those macros
                > for that?
                >
                > I often feel, that I am not thinking vim-y enough. ;o)
                >
                > Thanks a lot for all your help!
                >
                > Keep hacking!
                > mcc
                >
                >

                The {rhs} (right-hand side) of a mapping is exactly the sequence of keys as
                you would hit them to accomplish the desired action. In Insert mode you can
                move the cursor using <Left> <Right> etc., so instead of <Esc>?#<CR> you can
                use <Left><Left>. This means that you can leave out the # in the first place,
                and just use one <Left> to place the cursor before the }. You then remain in
                Insert mode to insert whatever you want through the keyboard after the mapping
                has finished:

                :imap <C-C><C-F>b {\bf }<Left>

                etc.

                If you want the _next_ use of <Esc> to move the cursor after the } then it
                becomes more intricate: you will need to use a function as {rhs} to return the
                required string and remap <Esc> as a side-effect; but "what you remap <Esc>
                to" must not only do the required cursor move but also unmap itself. In this
                case I don't think the game is worth the candle, especially if {\bf } {\it }
                {\sl } etc. can be nested. It may be simpler to just hit <Right> to go past
                the right-bracket when you want to close the "{\bf " or similar.

                Another possibility is to simply yank these strings (without the closing
                brace) into some registers (which will be saved in your viminfo so you do this
                only once, at the command-line):

                :let @b = '{\bf '
                :let @i = '{\it '
                :let @s = '{\sl '

                (Note the _single_ quotes.) Then, in Insert mode, <C-R>b will insert
                {\bf<Space> and similarly for the other two (even after you close and reopen
                Vim, without the need to reenter them). Hit } to close the (bold?) text area.


                Best regards,
                Tony.
              • Meino Christian Cramer
                From: A.J.Mechelynck Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 19:44:39 +0200 ... Hi Tony, as I said...I
                Message 7 of 15 , Oct 1, 2006
                  From: "A.J.Mechelynck" <antoine.mechelynck@...>
                  Subject: Re: Mapping of keysequences...
                  Date: Sun, 01 Oct 2006 19:44:39 +0200

                  > Meino Christian Cramer wrote:
                  > [...]
                  > > Hi Tony !
                  > >
                  > > nice to read you again! And thank you very much for your
                  > > help,help,help... :) <- BIG smiley!
                  > >
                  > > Slowly and surely I get my TeX macro working...
                  > >
                  > > What I have now is the following:
                  > >
                  > > inoremap <C-C><C-F>b {\bf #}<ESC>?#<CR>c/}<CR>
                  > > inoremap <C-C><C-F>i {\it #}<ESC>?#<CR>c/}<CR>
                  > > inoremap <C-C><C-F>s {\sl #}<ESC>?#<CR>c/}<CR>
                  > >
                  > > which "works". A last wish I would have is: After 'c'hanging the '#'
                  > > to what I really want to typeset I will press <ESC> to leave
                  > > 'c'hanging and insert mode. But my cursor still is inside of the {}....
                  > >
                  > > Is it possible to let the macros recognize the pressing of '<ESC>'
                  > > and then jump behind the '}' and may be entering 'i'nsert mode again?
                  > >
                  > > Or may be I need a completly different implementation of those macros
                  > > for that?
                  > >
                  > > I often feel, that I am not thinking vim-y enough. ;o)
                  > >
                  > > Thanks a lot for all your help!
                  > >
                  > > Keep hacking!
                  > > mcc
                  > >
                  > >
                  >
                  > The {rhs} (right-hand side) of a mapping is exactly the sequence of keys as
                  > you would hit them to accomplish the desired action. In Insert mode you can
                  > move the cursor using <Left> <Right> etc., so instead of <Esc>?#<CR> you can
                  > use <Left><Left>. This means that you can leave out the # in the first place,
                  > and just use one <Left> to place the cursor before the }. You then remain in
                  > Insert mode to insert whatever you want through the keyboard after the mapping
                  > has finished:
                  >
                  > :imap <C-C><C-F>b {\bf }<Left>
                  >
                  > etc.
                  >
                  > If you want the _next_ use of <Esc> to move the cursor after the } then it
                  > becomes more intricate: you will need to use a function as {rhs} to return the
                  > required string and remap <Esc> as a side-effect; but "what you remap <Esc>
                  > to" must not only do the required cursor move but also unmap itself. In this
                  > case I don't think the game is worth the candle, especially if {\bf } {\it }
                  > {\sl } etc. can be nested. It may be simpler to just hit <Right> to go past
                  > the right-bracket when you want to close the "{\bf " or similar.
                  >
                  > Another possibility is to simply yank these strings (without the closing
                  > brace) into some registers (which will be saved in your viminfo so you do this
                  > only once, at the command-line):
                  >
                  > :let @b = '{\bf '
                  > :let @i = '{\it '
                  > :let @s = '{\sl '
                  >
                  > (Note the _single_ quotes.) Then, in Insert mode, <C-R>b will insert
                  > {\bf<Space> and similarly for the other two (even after you close and reopen
                  > Vim, without the need to reenter them). Hit } to close the (bold?) text area.
                  >
                  >
                  > Best regards,
                  > Tony.
                  >

                  Hi Tony,

                  as I said...I am currently not thinking vim-y enough ... :)))))))

                  With "<Left>" it is so much easier to achieve the wanted effect than
                  jumping betwen the modes and inserting things only for the purpose of
                  replaceing them with something different...

                  And the register-trick with @b,@f,@s is even more simpler!

                  One last question:
                  Will it hurt or eat up my system resources :) when I insert the 'let'
                  commands into my .vimrc?
                  This is to avoid haveing "one part" of a macro in .vimrc and the
                  other one in .viminfo....not to confuse myself right in the beginning
                  of learning of vim if not needed.

                  Thank you very much, Tony !

                  Keep hacking!
                  mcc
                • A.J.Mechelynck
                  ... well, it will just (after the first time) place into your registers what is already there because your viminfo automatically saves it from session to
                  Message 8 of 15 , Oct 1, 2006
                    Meino Christian Cramer wrote:
                    > From: "A.J.Mechelynck" <antoine.mechelynck@...>
                    > Subject: Re: Mapping of keysequences...
                    > Date: Sun, 01 Oct 2006 19:44:39 +0200
                    >
                    >> Meino Christian Cramer wrote:
                    >> [...]
                    >>> Hi Tony !
                    >>>
                    >>> nice to read you again! And thank you very much for your
                    >>> help,help,help... :) <- BIG smiley!
                    >>>
                    >>> Slowly and surely I get my TeX macro working...
                    >>>
                    >>> What I have now is the following:
                    >>>
                    >>> inoremap <C-C><C-F>b {\bf #}<ESC>?#<CR>c/}<CR>
                    >>> inoremap <C-C><C-F>i {\it #}<ESC>?#<CR>c/}<CR>
                    >>> inoremap <C-C><C-F>s {\sl #}<ESC>?#<CR>c/}<CR>
                    >>>
                    >>> which "works". A last wish I would have is: After 'c'hanging the '#'
                    >>> to what I really want to typeset I will press <ESC> to leave
                    >>> 'c'hanging and insert mode. But my cursor still is inside of the {}....
                    >>>
                    >>> Is it possible to let the macros recognize the pressing of '<ESC>'
                    >>> and then jump behind the '}' and may be entering 'i'nsert mode again?
                    >>>
                    >>> Or may be I need a completly different implementation of those macros
                    >>> for that?
                    >>>
                    >>> I often feel, that I am not thinking vim-y enough. ;o)
                    >>>
                    >>> Thanks a lot for all your help!
                    >>>
                    >>> Keep hacking!
                    >>> mcc
                    >>>
                    >>>
                    >> The {rhs} (right-hand side) of a mapping is exactly the sequence of keys as
                    >> you would hit them to accomplish the desired action. In Insert mode you can
                    >> move the cursor using <Left> <Right> etc., so instead of <Esc>?#<CR> you can
                    >> use <Left><Left>. This means that you can leave out the # in the first place,
                    >> and just use one <Left> to place the cursor before the }. You then remain in
                    >> Insert mode to insert whatever you want through the keyboard after the mapping
                    >> has finished:
                    >>
                    >> :imap <C-C><C-F>b {\bf }<Left>
                    >>
                    >> etc.
                    >>
                    >> If you want the _next_ use of <Esc> to move the cursor after the } then it
                    >> becomes more intricate: you will need to use a function as {rhs} to return the
                    >> required string and remap <Esc> as a side-effect; but "what you remap <Esc>
                    >> to" must not only do the required cursor move but also unmap itself. In this
                    >> case I don't think the game is worth the candle, especially if {\bf } {\it }
                    >> {\sl } etc. can be nested. It may be simpler to just hit <Right> to go past
                    >> the right-bracket when you want to close the "{\bf " or similar.
                    >>
                    >> Another possibility is to simply yank these strings (without the closing
                    >> brace) into some registers (which will be saved in your viminfo so you do this
                    >> only once, at the command-line):
                    >>
                    >> :let @b = '{\bf '
                    >> :let @i = '{\it '
                    >> :let @s = '{\sl '
                    >>
                    >> (Note the _single_ quotes.) Then, in Insert mode, <C-R>b will insert
                    >> {\bf<Space> and similarly for the other two (even after you close and reopen
                    >> Vim, without the need to reenter them). Hit } to close the (bold?) text area.
                    >>
                    >>
                    >> Best regards,
                    >> Tony.
                    >>
                    >
                    > Hi Tony,
                    >
                    > as I said...I am currently not thinking vim-y enough ... :)))))))
                    >
                    > With "<Left>" it is so much easier to achieve the wanted effect than
                    > jumping betwen the modes and inserting things only for the purpose of
                    > replaceing them with something different...
                    >
                    > And the register-trick with @b,@f,@s is even more simpler!
                    >
                    > One last question:
                    > Will it hurt or eat up my system resources :) when I insert the 'let'
                    > commands into my .vimrc?

                    well, it will just (after the first time) place into your registers what is
                    already there because your viminfo automatically saves it from session to
                    session. The "resources" it "eats up" are, I suppose, a few bytes of vimrc
                    disk space and a few milliseconds of startup time ;-). Nothing much to worry
                    about.

                    > This is to avoid haveing "one part" of a macro in .vimrc and the
                    > other one in .viminfo....not to confuse myself right in the beginning
                    > of learning of vim if not needed.
                    >
                    > Thank you very much, Tony !
                    >
                    > Keep hacking!
                    > mcc
                    >
                    >
                    >
                    >

                    And if you put these three values in the registers, you don't need anything
                    for this in the vimrc -- there is no "other part". Ctrl-R letter (in Insert
                    mode) directly invokes the corresponding register. Similarly Ctrl-R + (the
                    system clipboard), Ctrl-R / (the latest search pattern), etc.

                    There are several ways to invoke each register:

                    "x in Normal mode commands (y, d, p etc.)
                    @x in expressions and in :let, :redir, etc.
                    x in the argument to :yank, :put etc.
                    "x" in the first argument to setreg() etc.
                    <C-R>x in Insert/Replace and Command-line modes

                    In all these cases, the register is the same if the letter is the same. And if
                    you ever forget what is in your registers, there is always the ":reg[isters]"
                    command.


                    Best regards,
                    Tony.
                  • Meino Christian Cramer
                    From: A.J.Mechelynck Subject: Re: Mapping of keysequences... Date: Sun, 01 Oct 2006 20:34:31 +0200 ... Thanks for all, Tony!!!
                    Message 9 of 15 , Oct 1, 2006
                      From: "A.J.Mechelynck" <antoine.mechelynck@...>
                      Subject: Re: Mapping of keysequences...
                      Date: Sun, 01 Oct 2006 20:34:31 +0200

                      > Meino Christian Cramer wrote:
                      > > From: "A.J.Mechelynck" <antoine.mechelynck@...>
                      > > Subject: Re: Mapping of keysequences...
                      > > Date: Sun, 01 Oct 2006 19:44:39 +0200
                      > >
                      > >> Meino Christian Cramer wrote:
                      > >> [...]
                      > >>> Hi Tony !
                      > >>>
                      > >>> nice to read you again! And thank you very much for your
                      > >>> help,help,help... :) <- BIG smiley!
                      > >>>
                      > >>> Slowly and surely I get my TeX macro working...
                      > >>>
                      > >>> What I have now is the following:
                      > >>>
                      > >>> inoremap <C-C><C-F>b {\bf #}<ESC>?#<CR>c/}<CR>
                      > >>> inoremap <C-C><C-F>i {\it #}<ESC>?#<CR>c/}<CR>
                      > >>> inoremap <C-C><C-F>s {\sl #}<ESC>?#<CR>c/}<CR>
                      > >>>
                      > >>> which "works". A last wish I would have is: After 'c'hanging the '#'
                      > >>> to what I really want to typeset I will press <ESC> to leave
                      > >>> 'c'hanging and insert mode. But my cursor still is inside of the {}....
                      > >>>
                      > >>> Is it possible to let the macros recognize the pressing of '<ESC>'
                      > >>> and then jump behind the '}' and may be entering 'i'nsert mode again?
                      > >>>
                      > >>> Or may be I need a completly different implementation of those macros
                      > >>> for that?
                      > >>>
                      > >>> I often feel, that I am not thinking vim-y enough. ;o)
                      > >>>
                      > >>> Thanks a lot for all your help!
                      > >>>
                      > >>> Keep hacking!
                      > >>> mcc
                      > >>>
                      > >>>
                      > >> The {rhs} (right-hand side) of a mapping is exactly the sequence of keys as
                      > >> you would hit them to accomplish the desired action. In Insert mode you can
                      > >> move the cursor using <Left> <Right> etc., so instead of <Esc>?#<CR> you can
                      > >> use <Left><Left>. This means that you can leave out the # in the first place,
                      > >> and just use one <Left> to place the cursor before the }. You then remain in
                      > >> Insert mode to insert whatever you want through the keyboard after the mapping
                      > >> has finished:
                      > >>
                      > >> :imap <C-C><C-F>b {\bf }<Left>
                      > >>
                      > >> etc.
                      > >>
                      > >> If you want the _next_ use of <Esc> to move the cursor after the } then it
                      > >> becomes more intricate: you will need to use a function as {rhs} to return the
                      > >> required string and remap <Esc> as a side-effect; but "what you remap <Esc>
                      > >> to" must not only do the required cursor move but also unmap itself. In this
                      > >> case I don't think the game is worth the candle, especially if {\bf } {\it }
                      > >> {\sl } etc. can be nested. It may be simpler to just hit <Right> to go past
                      > >> the right-bracket when you want to close the "{\bf " or similar.
                      > >>
                      > >> Another possibility is to simply yank these strings (without the closing
                      > >> brace) into some registers (which will be saved in your viminfo so you do this
                      > >> only once, at the command-line):
                      > >>
                      > >> :let @b = '{\bf '
                      > >> :let @i = '{\it '
                      > >> :let @s = '{\sl '
                      > >>
                      > >> (Note the _single_ quotes.) Then, in Insert mode, <C-R>b will insert
                      > >> {\bf<Space> and similarly for the other two (even after you close and reopen
                      > >> Vim, without the need to reenter them). Hit } to close the (bold?) text area.
                      > >>
                      > >>
                      > >> Best regards,
                      > >> Tony.
                      > >>
                      > >
                      > > Hi Tony,
                      > >
                      > > as I said...I am currently not thinking vim-y enough ... :)))))))
                      > >
                      > > With "<Left>" it is so much easier to achieve the wanted effect than
                      > > jumping betwen the modes and inserting things only for the purpose of
                      > > replaceing them with something different...
                      > >
                      > > And the register-trick with @b,@f,@s is even more simpler!
                      > >
                      > > One last question:
                      > > Will it hurt or eat up my system resources :) when I insert the 'let'
                      > > commands into my .vimrc?
                      >
                      > well, it will just (after the first time) place into your registers what is
                      > already there because your viminfo automatically saves it from session to
                      > session. The "resources" it "eats up" are, I suppose, a few bytes of vimrc
                      > disk space and a few milliseconds of startup time ;-). Nothing much to worry
                      > about.
                      >
                      > > This is to avoid haveing "one part" of a macro in .vimrc and the
                      > > other one in .viminfo....not to confuse myself right in the beginning
                      > > of learning of vim if not needed.
                      > >
                      > > Thank you very much, Tony !
                      > >
                      > > Keep hacking!
                      > > mcc
                      > >
                      > >
                      > >
                      > >
                      >
                      > And if you put these three values in the registers, you don't need anything
                      > for this in the vimrc -- there is no "other part". Ctrl-R letter (in Insert
                      > mode) directly invokes the corresponding register. Similarly Ctrl-R + (the
                      > system clipboard), Ctrl-R / (the latest search pattern), etc.
                      >
                      > There are several ways to invoke each register:
                      >
                      > "x in Normal mode commands (y, d, p etc.)
                      > @x in expressions and in :let, :redir, etc.
                      > x in the argument to :yank, :put etc.
                      > "x" in the first argument to setreg() etc.
                      > <C-R>x in Insert/Replace and Command-line modes
                      >
                      > In all these cases, the register is the same if the letter is the same. And if
                      > you ever forget what is in your registers, there is always the ":reg[isters]"
                      > command.
                      >
                      >
                      > Best regards,
                      > Tony.
                      >

                      Thanks for all, Tony!!! :O)

                      I think Bram should add

                      :he Tony

                      -support in vim which prints your email address...
                      ....or may be it is not what you really want, isn't ir ;O)

                      (just kidding)

                      Keep hacking!
                      mcc
                    • A.J.Mechelynck
                      Meino Christian Cramer wrote: [...] ... Actually, my personal maibox is so full of spam that I read it only when there s no outstanding mail on the vim-lists
                      Message 10 of 15 , Oct 1, 2006
                        Meino Christian Cramer wrote:
                        [...]
                        > I think Bram should add
                        >
                        > :he Tony
                        >
                        > -support in vim which prints your email address...
                        > ....or may be it is not what you really want, isn't ir ;O)
                        >
                        > (just kidding)
                        >
                        > Keep hacking!
                        > mcc
                        >

                        :-D

                        Actually, my personal maibox is so full of spam that I read it only when
                        there's no outstanding mail on the vim-lists (or from Bugzilla, or from a
                        small number of close friends). If you want to get at me, post on the list. I
                        also "committed" (as one commits crimes or misdemeanors, I suppose) a few tips
                        and scripts at vim-online, but not as many and probably not as good as some
                        other people like Benji Fisher, Dr. Chip Campbell, and others; and a few pages
                        about Vim on my personal site.

                        Don't hack too hard or too long, or you will we stuck with only shavings.


                        Best regards,
                        Tony.
                      • Andy Wokula
                        ... Add it yourself ... *tony.txt* Tony s mail address *Tony* A.J.Mechelynck vim:tw=78:ts=8:ft=help:norl: . ...
                        Message 11 of 15 , Oct 2, 2006
                          Meino Christian Cramer schrieb:
                          > Thanks for all, Tony!!! :O)
                          >
                          > I think Bram should add
                          >
                          > :he Tony
                          >
                          > -support in vim which prints your email address...
                          > ....or may be it is not what you really want, isn't ir ;O)
                          >
                          > (just kidding)
                          >
                          > Keep hacking!
                          > mcc

                          Add it yourself

                          :e ~/.vim/doc/tony.txt
                          :i
                          *tony.txt* Tony's mail address

                          *Tony* "A.J.Mechelynck" <antoine(dot)mechelynck(at)skynet(dot)be>

                          vim:tw=78:ts=8:ft=help:norl:
                          .
                          :w
                          :helptags ~/.vim/doc
                          :he Tony

                          :-)

                          Andy





                          ___________________________________________________________
                          Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
                        • Brian McKee
                          ... Hash: SHA1 ... Ya know - not only is that funny - it s useful ! It made me realize I can make my own crib sheet for the stuff I can t remember and embed it
                          Message 12 of 15 , Oct 2, 2006
                            -----BEGIN PGP SIGNED MESSAGE-----
                            Hash: SHA1


                            On 2-Oct-06, at 3:51 PM, Andy Wokula wrote:

                            > Meino Christian Cramer schrieb:
                            >> Thanks for all, Tony!!! :O)
                            >>
                            >> I think Bram should add
                            >>
                            >> :he Tony
                            >
                            > Add it yourself
                            >
                            > :e ~/.vim/doc/tony.txt
                            > :i
                            > *tony.txt* Tony's mail address
                            >
                            > *Tony* "A.J.Mechelynck" <antoine(dot)mechelynck(at)skynet(dot)be>
                            >
                            > vim:tw=78:ts=8:ft=help:norl:
                            > .
                            > :w
                            > :helptags ~/.vim/doc
                            > :he Tony
                            >



                            Ya know - not only is that funny - it's useful !
                            It made me realize I can make my own crib sheet for the stuff I can't
                            remember and embed it right in Vim!
                            Cool....

                            e.g. :'<,'>!sort -t "^I" -k 9
                            I use that once a month or so, but never remember it... now it's :he
                            sort9


                            Thanks!
                            Brian
                            -----BEGIN PGP SIGNATURE-----
                            Version: GnuPG v1.4.1 (Darwin)

                            iD8DBQFFIXh3GnOmb9xIQHQRApcaAKCbBMBVNJB2kf6U5nTUU0cXB61ZfwCgpZYH
                            axmyL2MpQZZuzXScYpdFPwE=
                            =UOqL
                            -----END PGP SIGNATURE-----
                          • A.J.Mechelynck
                            ... The principle of creating cribsheet helpfiles in ~/.vim/doc is certainly useful (though not for my email addy which I don t read as often as vim, vim-dev
                            Message 13 of 15 , Oct 3, 2006
                              Brian McKee wrote:
                              > -----BEGIN PGP SIGNED MESSAGE-----
                              > Hash: SHA1
                              >
                              >
                              > On 2-Oct-06, at 3:51 PM, Andy Wokula wrote:
                              >
                              >> Meino Christian Cramer schrieb:
                              >>> Thanks for all, Tony!!! :O)
                              >>>
                              >>> I think Bram should add
                              >>>
                              >>> :he Tony
                              >>
                              >> Add it yourself
                              >>
                              >> :e ~/.vim/doc/tony.txt
                              >> :i
                              >> *tony.txt* Tony's mail address
                              >>
                              >> *Tony* "A.J.Mechelynck" <antoine(dot)mechelynck(at)skynet(dot)be>
                              >>
                              >> vim:tw=78:ts=8:ft=help:norl:
                              >> .
                              >> :w
                              >> :helptags ~/.vim/doc
                              >> :he Tony
                              >>
                              >
                              >
                              >
                              > Ya know - not only is that funny - it's useful !
                              > It made me realize I can make my own crib sheet for the stuff I can't
                              > remember and embed it right in Vim!
                              > Cool....
                              >
                              > e.g. :'<,'>!sort -t "^I" -k 9
                              > I use that once a month or so, but never remember it... now it's :he sort9
                              >
                              >
                              > Thanks!
                              > Brian

                              The principle of creating "cribsheet" helpfiles in ~/.vim/doc is certainly
                              useful (though not for my email addy which I don't read as often as vim,
                              vim-dev or vim-multibyte @...).

                              The above is for external sort. Do you know Vim 7 has an internal sort (see
                              :help :sort)?


                              Best regards,
                              Tony.
                            Your message has been successfully submitted and would be delivered to recipients shortly.