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

mapping question

Expand Messages
  • Sean Hubbell
    Hello, Would anyone please let me know what I am doing wrong with the following mapping: nnoremap :let z=expand( DBR_ . expand
    Message 1 of 25 , Aug 19, 2005
      Hello,

      Would anyone please let me know what I am doing wrong with the
      following mapping:

      nnoremap <F3> :let z=expand("DBR_" . expand
      ("<cword>"))<CR>%s;\=expand("<cword>");\=z;g<CR>


      I would like to be able to edit a file and modify the word under the
      cursor for all occurences of that word in the document with a prefix.
      For example,


      This that the other other

      would be

      This that the DBR_other DBR_other

      if I selected the "other" word in the file.

      Thanks in advance,

      Sean
    • Sean Hubbell
      ... Thanks Keith. Sean
      Message 2 of 25 , Aug 19, 2005
        Keith W. Roberts wrote:

        >
        >
        >
        >
        >>-----Original Message-----
        >>From: Sean Hubbell [mailto:shubbell@...]
        >>Sent: Friday, August 19, 2005 6:18 AM
        >>To: vim mailing list
        >>Subject: mapping question
        >>
        >>Hello,
        >>
        >> Would anyone please let me know what I am doing wrong with the
        >>following mapping:
        >>
        >>nnoremap <F3> :let z=expand("DBR_" . expand
        >>("<cword>"))<CR>%s;\=expand("<cword>");\=z;g<CR>
        >>
        >>
        > ^^
        >Insert : between the characters above carets. The reason is that the <cr>
        >executes the first Ex command, putting you back in Normal mode.
        >
        >-Keith
        >
        >
        >
        >
        >
        >
        Thanks Keith.

        Sean
      • Sean Hubbell
        ... Thanks (again) for the great help Tim. I have tried a few things. I did not know how to get around the expand in the substitute problem and this takes care
        Message 3 of 25 , Aug 19, 2005
          Tim Chase wrote:

          >> Would anyone please let me know what I am doing wrong with the
          >> following mapping:
          >>
          >> nnoremap <F3> :let z=expand("DBR_" . expand
          >> ("<cword>"))<CR>%s;\=expand("<cword>");\=z;g<CR>
          >
          >
          > A couple things stand out as possible candidates for trouble
          >
          > -you're expanding something that's already been expanded...I don't
          > know if it's intentional, but it stood out as a bit odd. It might make
          > sense in the context you're using it. Perhaps to look for a file-name
          > consisting of "DBR_" prefixed to the word currently under the cursor,
          > returning an empty string if the file doesn't exist?
          >
          > -the first <CR> terminates the Ex command, so the following "%" acts
          > in normal mode (as this is a normal-mode mapping). This is the "jump
          > to matching paren/brace" command. Thus, you may need another colon in
          > there.
          >
          > -you're using "\=" in the search clause of the substitute. In this
          > context, it means "zero-or-one match of the previous atom", and
          > doesn't evaluate the expand() call. For this, you may have to wrap
          > matters in an exec() call.
          >
          > However, if I understand what you're trying to do, perhaps the
          > following mapping will do what you're trying to do?
          >
          > :nnoremap <f3> :%s;<c-r><c-w>;DBR_&;g<cr>
          >
          > This makes use of the fact that in command-line mode, you can use
          > control+R followed by control+W to insert the word in your document on
          > which the cursor is currently sitting. Something akin to using
          > expand("<cword>").
          >
          > For more info, check out
          >
          > :help c_CTRL-R_CTRL-W
          >
          > (where there are also bits for the filename matching under the cursor,
          > WORD under the cursor, etc)
          >
          > Hope this gives you some leads to try,
          >
          > -tim
          >
          >
          Thanks (again) for the great help Tim. I have tried a few things. I did
          not know how to get around the expand in the substitute problem and this
          takes care of that.

          Sean
        • Sean Hubbell
          ... How would one add word boundaries to c-w? Sean
          Message 4 of 25 , Aug 19, 2005
            Tim Chase wrote:

            >> Would anyone please let me know what I am doing wrong with the
            >> following mapping:
            >>
            >> nnoremap <F3> :let z=expand("DBR_" . expand
            >> ("<cword>"))<CR>%s;\=expand("<cword>");\=z;g<CR>
            >
            >
            > A couple things stand out as possible candidates for trouble
            >
            > -you're expanding something that's already been expanded...I don't
            > know if it's intentional, but it stood out as a bit odd. It might make
            > sense in the context you're using it. Perhaps to look for a file-name
            > consisting of "DBR_" prefixed to the word currently under the cursor,
            > returning an empty string if the file doesn't exist?
            >
            > -the first <CR> terminates the Ex command, so the following "%" acts
            > in normal mode (as this is a normal-mode mapping). This is the "jump
            > to matching paren/brace" command. Thus, you may need another colon in
            > there.
            >
            > -you're using "\=" in the search clause of the substitute. In this
            > context, it means "zero-or-one match of the previous atom", and
            > doesn't evaluate the expand() call. For this, you may have to wrap
            > matters in an exec() call.
            >
            > However, if I understand what you're trying to do, perhaps the
            > following mapping will do what you're trying to do?
            >
            > :nnoremap <f3> :%s;<c-r><c-w>;DBR_&;g<cr>
            >
            > This makes use of the fact that in command-line mode, you can use
            > control+R followed by control+W to insert the word in your document on
            > which the cursor is currently sitting. Something akin to using
            > expand("<cword>").
            >
            > For more info, check out
            >
            > :help c_CTRL-R_CTRL-W
            >
            > (where there are also bits for the filename matching under the cursor,
            > WORD under the cursor, etc)
            >
            > Hope this gives you some leads to try,
            >
            > -tim
            >
            >
            >
            >
            >
            >
            How would one add word boundaries to c-w?

            Sean
          • Keith W. Roberts
            ... ^^ Insert : between the characters above carets. The reason is that the executes the first Ex command, putting you back in Normal mode. -Keith
            Message 5 of 25 , Aug 19, 2005
              > -----Original Message-----
              > From: Sean Hubbell [mailto:shubbell@...]
              > Sent: Friday, August 19, 2005 6:18 AM
              > To: vim mailing list
              > Subject: mapping question
              >
              > Hello,
              >
              > Would anyone please let me know what I am doing wrong with the
              > following mapping:
              >
              > nnoremap <F3> :let z=expand("DBR_" . expand
              > ("<cword>"))<CR>%s;\=expand("<cword>");\=z;g<CR>
              ^^
              Insert : between the characters above carets. The reason is that the <cr>
              executes the first Ex command, putting you back in Normal mode.

              -Keith
            • Sean Hubbell
              ... I noticed that the match seems to match from the current position to the end of the file. Is there a way to wrap this? Also, the icing on the cake would be
              Message 6 of 25 , Aug 19, 2005
                Tim Chase wrote:

                >>> :nnoremap <f3> :%s;<c-r><c-w>;DBR_&;g<cr>
                >>
                > [trim]
                >
                >> How would one add word boundaries to c-w?
                >
                >
                > The ^R^W should default to using word boundaries, as defined (IIUC) by
                > the contents of your 'iskeyword' settings. If you want to include
                > anything that's non-whitespace, you want what Vim refers to as a
                > "WORD" rather than a "word"
                >
                > :help word
                > :help WORD
                >
                > (they're right next to each other, so if you go to the first one, just
                > keep reading :)
                >
                > To use a WORD instead, use
                >
                > <c-r><c-a>
                >
                > instead of
                >
                > <c-r><c-w>
                >
                > If, instead, you want to add the word boundaries to the *searching*,
                > just use the standard \< and \> as in
                >
                > nnoremap <f3> :%s;\<<c-r><c-w>\>;DBR_&;g<cr>
                >
                > which seems to work for me.
                >
                > -tim
                >
                >
                >
                >
                >
                >
                I noticed that the match seems to match from the current position to the
                end of the file. Is there a way to wrap this?
                Also, the icing on the cake would be to disallow executing this twice.
                For example, given:

                DBR_this

                do not allow a substitution since there already is a prefix?
                I can live without this, but it would be nice.


                Thanks again for the great help.

                Sean
              • Tim Chase
                ... A couple things stand out as possible candidates for trouble -you re expanding something that s already been expanded...I don t know if it s intentional,
                Message 7 of 25 , Aug 19, 2005
                  > Would anyone please let me know what I am doing wrong with the
                  > following mapping:
                  >
                  > nnoremap <F3> :let z=expand("DBR_" . expand
                  > ("<cword>"))<CR>%s;\=expand("<cword>");\=z;g<CR>

                  A couple things stand out as possible candidates for trouble

                  -you're expanding something that's already been expanded...I
                  don't know if it's intentional, but it stood out as a bit odd.
                  It might make sense in the context you're using it. Perhaps to
                  look for a file-name consisting of "DBR_" prefixed to the word
                  currently under the cursor, returning an empty string if the file
                  doesn't exist?

                  -the first <CR> terminates the Ex command, so the following "%"
                  acts in normal mode (as this is a normal-mode mapping). This is
                  the "jump to matching paren/brace" command. Thus, you may need
                  another colon in there.

                  -you're using "\=" in the search clause of the substitute. In
                  this context, it means "zero-or-one match of the previous atom",
                  and doesn't evaluate the expand() call. For this, you may have
                  to wrap matters in an exec() call.

                  However, if I understand what you're trying to do, perhaps the
                  following mapping will do what you're trying to do?

                  :nnoremap <f3> :%s;<c-r><c-w>;DBR_&;g<cr>

                  This makes use of the fact that in command-line mode, you can use
                  control+R followed by control+W to insert the word in your
                  document on which the cursor is currently sitting. Something
                  akin to using expand("<cword>").

                  For more info, check out

                  :help c_CTRL-R_CTRL-W

                  (where there are also bits for the filename matching under the
                  cursor, WORD under the cursor, etc)

                  Hope this gives you some leads to try,

                  -tim
                • Sean Hubbell
                  ... Running gvim 6.3.46 on cAos, CTRL-RCTRL-W does not default to using word boundaries. My iskeyword settings contain the following: @,48-57,_,192-255 which
                  Message 8 of 25 , Aug 19, 2005
                    >> The ^R^W should default to using word boundaries, as defined (IIUC)
                    >> by the contents of your 'iskeyword' settings. If you want to include
                    >> anything that's non-whitespace, you want what Vim refers to as a
                    >> "WORD" rather than a "word"
                    >>
                    >> :help word
                    >> :help WORD
                    >>
                    >
                    Running gvim 6.3.46 on cAos, CTRL-RCTRL-W does not default to using word
                    boundaries. My iskeyword settings contain the following:

                    "@,48-57,_,192-255" which notes as the correct default setting. I can
                    investigate this more if anyone would like?

                    ???

                    Sean
                  • Keith W. Roberts
                    ... -Keith
                    Message 9 of 25 , Aug 19, 2005
                      > -----Original Message-----
                      > From: Sean Hubbell [mailto:shubbell@...]
                      > Sent: Friday, August 19, 2005 7:56 AM
                      > To: Tim Chase
                      > Cc: vim mailing list
                      > Subject: Re: mapping question
                      >
                      > Tim Chase wrote:
                      >
                      > >> Would anyone please let me know what I am doing wrong with the
                      > >> following mapping:
                      > >>
                      > >> nnoremap <F3> :let z=expand("DBR_" . expand
                      > >> ("<cword>"))<CR>%s;\=expand("<cword>");\=z;g<CR>
                      > >
                      > >
                      > > A couple things stand out as possible candidates for trouble
                      > >
                      > > -you're expanding something that's already been expanded...I don't
                      > > know if it's intentional, but it stood out as a bit odd. It
                      > might make
                      > > sense in the context you're using it. Perhaps to look for a
                      > file-name
                      > > consisting of "DBR_" prefixed to the word currently under
                      > the cursor,
                      > > returning an empty string if the file doesn't exist?
                      > >
                      > > -the first <CR> terminates the Ex command, so the following
                      > "%" acts
                      > > in normal mode (as this is a normal-mode mapping). This is
                      > the "jump
                      > > to matching paren/brace" command. Thus, you may need
                      > another colon in
                      > > there.
                      > >
                      > > -you're using "\=" in the search clause of the substitute. In this
                      > > context, it means "zero-or-one match of the previous atom", and
                      > > doesn't evaluate the expand() call. For this, you may have to wrap
                      > > matters in an exec() call.
                      > >
                      > > However, if I understand what you're trying to do, perhaps the
                      > > following mapping will do what you're trying to do?
                      > >
                      > > :nnoremap <f3> :%s;<c-r><c-w>;DBR_&;g<cr>
                      > >
                      > > This makes use of the fact that in command-line mode, you can use
                      > > control+R followed by control+W to insert the word in your
                      > document on
                      > > which the cursor is currently sitting. Something akin to using
                      > > expand("<cword>").
                      > >
                      > > For more info, check out
                      > >
                      > > :help c_CTRL-R_CTRL-W
                      > >
                      > > (where there are also bits for the filename matching under
                      > the cursor,
                      > > WORD under the cursor, etc)
                      > >
                      > > Hope this gives you some leads to try,
                      > >
                      > > -tim
                      > >
                      > >
                      > >
                      > >
                      > >
                      > >
                      > How would one add word boundaries to c-w?
                      >
                      > Sean
                      >
                      >

                      Surround with \< and \>, as:

                      :nnoremap <f3> :%s;\<<c-r><c-w>\>;DBR_&;g<cr>

                      :h pattern-atoms

                      -Keith
                    • Tim Chase
                      ... [trim] ... The ^R^W should default to using word boundaries, as defined (IIUC) by the contents of your iskeyword settings. If you want to include
                      Message 10 of 25 , Aug 19, 2005
                        >> :nnoremap <f3> :%s;<c-r><c-w>;DBR_&;g<cr>
                        [trim]
                        > How would one add word boundaries to c-w?

                        The ^R^W should default to using word boundaries, as defined
                        (IIUC) by the contents of your 'iskeyword' settings. If you want
                        to include anything that's non-whitespace, you want what Vim
                        refers to as a "WORD" rather than a "word"

                        :help word
                        :help WORD

                        (they're right next to each other, so if you go to the first one,
                        just keep reading :)

                        To use a WORD instead, use

                        <c-r><c-a>

                        instead of

                        <c-r><c-w>

                        If, instead, you want to add the word boundaries to the
                        *searching*, just use the standard \< and \> as in

                        nnoremap <f3> :%s;\<<c-r><c-w>\>;DBR_&;g<cr>

                        which seems to work for me.

                        -tim
                      • Tim Chase
                        ... I m not quite sure I follow you...because of the % in the mapping, it should be applied to all lines in the file, not just from the current line to the
                        Message 11 of 25 , Aug 19, 2005
                          > I noticed that the match seems to match from the current position to the
                          > end of the file. Is there a way to wrap this?

                          I'm not quite sure I follow you...because of the "%" in the
                          mapping, it should be applied to all lines in the file, not just
                          from the current line to the end of file. I tried it here and it
                          replaced stuff above the current location just fine. You might
                          want to check your example (things like spelling, or occasions
                          for which there aren't word-boundaries around the missing case,
                          or something of the sort)

                          > Also, the icing on the cake would be to disallow executing this twice.
                          > For example, given:
                          >
                          > DBR_this
                          >
                          > do not allow a substitution since there already is a prefix?
                          > I can live without this, but it would be nice.

                          A little wrapping in an "if" statement (to ensure that the word
                          currently under the cursor doesn't begin with "DBR_") should do
                          the trick:

                          nnoremap <f3> :if match(expand("<cword>"), "^DBR_") < 0 <bar>
                          %s;\<<c-r><c-w>\>;DBR_&;g <bar> endif<cr>

                          If you shift to using WORDs instead, be sure to change both the
                          <cword> and the <c-r><c-w> to <cWORD> and <c-r><c-a>

                          -tim
                        • Keith W. Roberts
                          ... Hey, that s news even to me! :) The or just determines what the boundaries will be of the text *selected for inclusion*; they don t enforce
                          Message 12 of 25 , Aug 19, 2005
                            > -----Original Message-----
                            > From: Sean Hubbell [mailto:shubbell@...]
                            > Sent: Friday, August 19, 2005 8:13 AM
                            > To: Tim Chase
                            > Cc: vim mailing list
                            > Subject: Re: mapping question
                            >
                            > Tim Chase wrote:
                            >
                            > >>> :nnoremap <f3> :%s;<c-r><c-w>;DBR_&;g<cr>
                            > >>
                            > > [trim]
                            > >
                            > >> How would one add word boundaries to c-w?
                            > >
                            > >
                            > > The ^R^W should default to using word boundaries, as
                            > defined (IIUC) by
                            > > the contents of your 'iskeyword' settings. If you want to include
                            > > anything that's non-whitespace, you want what Vim refers to as a
                            > > "WORD" rather than a "word"
                            > >
                            > > :help word
                            > > :help WORD
                            > >
                            > > (they're right next to each other, so if you go to the
                            > first one, just
                            > > keep reading :)
                            > >
                            > > To use a WORD instead, use
                            > >
                            > > <c-r><c-a>

                            Hey, that's news even to me! :) The <c-w> or <c-a> just determines what the
                            boundaries will be of the text *selected for inclusion*; they don't enforce
                            that the text *searched for* be word bounded. Hence the use of \< and \>
                            fore and aft.

                            > > instead of
                            > >
                            > > <c-r><c-w>
                            > >
                            > > If, instead, you want to add the word boundaries to the
                            > *searching*,
                            > > just use the standard \< and \> as in
                            > >
                            > > nnoremap <f3> :%s;\<<c-r><c-w>\>;DBR_&;g<cr>
                            > >
                            > > which seems to work for me.
                            > >
                            > > -tim
                            > >
                            > >
                            > >
                            > >
                            > >
                            > >
                            > I noticed that the match seems to match from the current
                            > position to the
                            > end of the file. Is there a way to wrap this?

                            Not sure what you mean by this. The % causes substitution in the entire
                            buffer (file). If you just do a search with /<c-r><c-w> then:
                            - if incsearch is set, you will see the "next" match hilighted
                            - when you hit Enter, if hlsearch is set, all the matches will be hilighted
                            - if repeat using 'n', you will see each successive match till the eof
                            (unless wrapscan is set, in which case it'll wrap to the top of file and
                            continue)

                            :h is
                            :h hls
                            :h ws

                            > Also, the icing on the cake would be to disallow executing
                            > this twice.
                            > For example, given:
                            >
                            > DBR_this
                            >
                            > do not allow a substitution since there already is a prefix?
                            > I can live without this, but it would be nice.

                            Well, ummm... if you are executing this map, presumably you're looking right
                            at the word, and can see that there's a prefix already there, but ... :))

                            Kidding aside, doing that gets into some of the hairier regex forms. I'll
                            let someone else tackle that one.

                            -Keith
                          • Tim Chase
                            ... Well, to modify my previous suggestion, how about this addition? nnoremap :if match(expand( ), ^DBR_ ) %s; ;DBR_&;g
                            Message 13 of 25 , Aug 19, 2005
                              > Well, ummm... if you are executing this map, presumably you're
                              > looking right at the word, and can see that there's a prefix
                              > already there, but ... :))

                              Well, to modify my previous suggestion, how about this addition?

                              nnoremap <f3> :if match(expand("<cword>"), "^DBR_") < 0 <bar>
                              %s;\<<c-r><c-w>\>;DBR_&;g <bar> else <bar> echoerr "Hey, doofus!
                              It's already got one! :*)" <bar> endif<cr>

                              just a little fun for ya... :)

                              -tim
                            • guido
                              ... but that gives following E10 error: E10: should be followed by /, ? or & I m sorry, but I don t understand this. Can somebody help me with this mapping?
                              Message 14 of 25 , Oct 28 1:35 PM
                                In help buffers following command nicely goes to the next hyperlink:
                                :call search('|\S\+|')

                                I tried following mapping:
                                :nmap s call search('|\S\+|')
                                but that gives following E10 error:
                                E10: \ should be followed by /, ? or &

                                I'm sorry, but I don't understand this.
                                Can somebody help me with this mapping?

                                TIA,

                                Guido


                                --~--~---------~--~----~------------~-------~--~----~
                                You received this message from the "vim_use" maillist.
                                For more information, visit http://www.vim.org/maillist.php
                                -~----------~----~----~----~------~----~------~--~---
                              • Tony Mechelynck
                                ... You need to put Vim into command-line mode (hence the colon at the start of the {rhs}). I don t understand how the E10 was triggered. You could also use a
                                Message 15 of 25 , Oct 28 2:18 PM
                                  guido wrote:
                                  > In help buffers following command nicely goes to the next hyperlink:
                                  > :call search('|\S\+|')
                                  >
                                  > I tried following mapping:
                                  > :nmap s call search('|\S\+|')

                                  :nmap s :call search('|\S\+|')<CR>

                                  > but that gives following E10 error:
                                  > E10: \ should be followed by /, ? or &
                                  >
                                  > I'm sorry, but I don't understand this.
                                  > Can somebody help me with this mapping?
                                  >
                                  > TIA,
                                  >
                                  > Guido

                                  You need to put Vim into command-line mode (hence the colon at the start of
                                  the {rhs}).

                                  I don't understand how the E10 was triggered.

                                  You could also use a plain search:

                                  /|\S\+|
                                  or
                                  :nmap <F2> /|\S\+|<CR>
                                  :nmap <S-F2> ?|\S\+|<CR>


                                  Best regards,
                                  Tony.
                                  --
                                  May Euell Gibbons eat your only copy of the manual!

                                  --~--~---------~--~----~------------~-------~--~----~
                                  You received this message from the "vim_use" maillist.
                                  For more information, visit http://www.vim.org/maillist.php
                                  -~----------~----~----~----~------~----~------~--~---
                                • Csaba Hoch
                                  ... You must escape the bars (that s why you got the error), and of course you have to put colon before the command and after the command, ... Csaba
                                  Message 16 of 25 , Oct 28 2:23 PM
                                    guido wrote:
                                    > In help buffers following command nicely goes to the next hyperlink:
                                    > :call search('|\S\+|')
                                    >
                                    > I tried following mapping:
                                    > :nmap s call search('|\S\+|')
                                    > but that gives following E10 error:
                                    > E10: \ should be followed by /, ? or &
                                    >
                                    > I'm sorry, but I don't understand this.
                                    > Can somebody help me with this mapping?

                                    You must escape the bars (that's why you got the error), and of course
                                    you have to put colon before the command and <cr> after the command,
                                    so the mapping:
                                    :nmap s :call search('\|\S\+\|')<cr>

                                    Csaba


                                    --~--~---------~--~----~------------~-------~--~----~
                                    You received this message from the "vim_use" maillist.
                                    For more information, visit http://www.vim.org/maillist.php
                                    -~----------~----~----~----~------~----~------~--~---
                                  • Bill McCarthy
                                    ... That also triggers the same error message. The following ... -- Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ You received this
                                    Message 17 of 25 , Oct 28 2:26 PM
                                      On Sun 28-Oct-07 4:18pm -0600, Tony Mechelynck wrote:

                                      > guido wrote:
                                      >> In help buffers following command nicely goes to the next
                                      >> hyperlink:
                                      >> :call search('|\S\+|')
                                      >>
                                      >> I tried following mapping:
                                      >> :nmap s call search('|\S\+|')
                                      >
                                      > :nmap s :call search('|\S\+|')<CR>

                                      That also triggers the same error message. The following
                                      appears to work:

                                      :nmap s :call search('\|\S\+\|')<CR>

                                      --
                                      Best regards,
                                      Bill


                                      --~--~---------~--~----~------------~-------~--~----~
                                      You received this message from the "vim_use" maillist.
                                      For more information, visit http://www.vim.org/maillist.php
                                      -~----------~----~----~----~------~----~------~--~---
                                    • Tony Mechelynck
                                      ... OOps! ... -- Syntactic sugar causes cancer of the semicolon. -- Epigrams in Programming, ACM SIGPLAN Sept. 1982
                                      Message 18 of 25 , Oct 28 2:28 PM
                                        Tony Mechelynck wrote:
                                        > guido wrote:
                                        >> In help buffers following command nicely goes to the next hyperlink:
                                        >> :call search('|\S\+|')
                                        >>
                                        >> I tried following mapping:
                                        >> :nmap s call search('|\S\+|')
                                        >
                                        > :nmap s :call search('|\S\+|')<CR>

                                        OOps!
                                        :nmap s :call search('<Bar><Bslash>S<Bslash>+<Bar>')<CR>

                                        >
                                        >> but that gives following E10 error:
                                        >> E10: \ should be followed by /, ? or &
                                        >>
                                        >> I'm sorry, but I don't understand this.
                                        >> Can somebody help me with this mapping?
                                        >>
                                        >> TIA,
                                        >>
                                        >> Guido
                                        >
                                        > You need to put Vim into command-line mode (hence the colon at the start of
                                        > the {rhs}).
                                        >
                                        > I don't understand how the E10 was triggered.
                                        >
                                        > You could also use a plain search:
                                        >
                                        > /|\S\+|
                                        > or
                                        > :nmap <F2> /|\S\+|<CR>
                                        > :nmap <S-F2> ?|\S\+|<CR>
                                        >
                                        >
                                        > Best regards,
                                        > Tony.
                                        --
                                        Syntactic sugar causes cancer of the semicolon.
                                        -- Epigrams in Programming, ACM SIGPLAN Sept. 1982


                                        --~--~---------~--~----~------------~-------~--~----~
                                        You received this message from the "vim_use" maillist.
                                        For more information, visit http://www.vim.org/maillist.php
                                        -~----------~----~----~----~------~----~------~--~---
                                      • A.Politz
                                        ... You need to prepend a colon, escape the bars and add a : nmap s :call search( | S + | ) See :h map_bar . -ap -- Ich hab geträumt, der
                                        Message 19 of 25 , Oct 28 2:31 PM
                                          guido wrote:

                                          >In help buffers following command nicely goes to the next hyperlink:
                                          >:call search('|\S\+|')
                                          >
                                          >I tried following mapping:
                                          >:nmap s call search('|\S\+|')
                                          >but that gives following E10 error:
                                          >E10: \ should be followed by /, ? or &
                                          >
                                          >I'm sorry, but I don't understand this.
                                          >Can somebody help me with this mapping?
                                          >
                                          >TIA,
                                          >
                                          >Guido
                                          >
                                          >
                                          >>
                                          >
                                          >
                                          You need to prepend a colon, escape the bars and
                                          add a <cr> :
                                          nmap <buffer> s :call search('\|\S\+\|')<cr>
                                          See ':h map_bar' .

                                          -ap


                                          --
                                          Ich hab geträumt, der Krieg wär vorbei.


                                          --~--~---------~--~----~------------~-------~--~----~
                                          You received this message from the "vim_use" maillist.
                                          For more information, visit http://www.vim.org/maillist.php
                                          -~----------~----~----~----~------~----~------~--~---
                                        • Tony Mechelynck
                                          ... I forgot that and | are special in a mapping. See my erratum (Re (2) etc.) Best regards, Tony. -- I can t complain, but sometimes I still do. -- Joe
                                          Message 20 of 25 , Oct 28 2:33 PM
                                            Bill McCarthy wrote:
                                            > On Sun 28-Oct-07 4:18pm -0600, Tony Mechelynck wrote:
                                            >
                                            >> guido wrote:
                                            >>> In help buffers following command nicely goes to the next
                                            >>> hyperlink:
                                            >>> :call search('|\S\+|')
                                            >>>
                                            >>> I tried following mapping:
                                            >>> :nmap s call search('|\S\+|')
                                            >> :nmap s :call search('|\S\+|')<CR>
                                            >
                                            > That also triggers the same error message. The following
                                            > appears to work:
                                            >
                                            > :nmap s :call search('\|\S\+\|')<CR>
                                            >

                                            I forgot that \ and | are special in a mapping. See my erratum (Re (2) etc.)


                                            Best regards,
                                            Tony.
                                            --
                                            "I can't complain, but sometimes I still do."
                                            -- Joe Walsh

                                            --~--~---------~--~----~------------~-------~--~----~
                                            You received this message from the "vim_use" maillist.
                                            For more information, visit http://www.vim.org/maillist.php
                                            -~----------~----~----~----~------~----~------~--~---
                                          • guido
                                            I am posting this reply to the original message, in order to thank all people that replied to it: Tony, Ap, Csaba, Bill. It s always amazing to experience the
                                            Message 21 of 25 , Oct 28 2:48 PM
                                              I am posting this reply to the original message, in order to thank all
                                              people that replied to it: Tony, Ap, Csaba, Bill.
                                              It's always amazing to experience the helpfulness of the vim
                                              community!

                                              I have now following mappings in ~/vim/ftplugin/help.vim:
                                              nmap <buffer> s :call search('<Bar><Bslash>S<Bslash>+<Bar>')<CR>
                                              nmap <buffer> S :call search('<Bar><Bslash>S<Bslash>+<Bar>', 'b')<CR>

                                              Is there a way to prevent this search string from appearing in the
                                              search history? This is really not useful to remember while always
                                              available through my mapping. It does push down the real search
                                              strings
                                              that I have used before.

                                              I could of course save the value of the @/ register, do the search and
                                              restore @/ from the saved value. That is already a bit better, but
                                              still
                                              the <Bar><Bslash>S<Bslash>+<Bar> pattern is then the next historic
                                              entry. I'd like to simply pop it off the search stack, but do not know
                                              how to achieve this.

                                              Guido.


                                              --~--~---------~--~----~------------~-------~--~----~
                                              You received this message from the "vim_use" maillist.
                                              For more information, visit http://www.vim.org/maillist.php
                                              -~----------~----~----~----~------~----~------~--~---
                                            • Hari Krishna Dara
                                              ... Are you sure the text passed to search() gets into history? That has not been my experience and I just verified again to confirm that it doesn t happen. --
                                              Message 22 of 25 , Oct 28 4:30 PM
                                                On Sun, 28 Oct 2007 at 2:48pm, guido wrote:

                                                >
                                                > I am posting this reply to the original message, in order to thank all
                                                > people that replied to it: Tony, Ap, Csaba, Bill.
                                                > It's always amazing to experience the helpfulness of the vim
                                                > community!
                                                >
                                                > I have now following mappings in ~/vim/ftplugin/help.vim:
                                                > nmap <buffer> s :call search('<Bar><Bslash>S<Bslash>+<Bar>')<CR>
                                                > nmap <buffer> S :call search('<Bar><Bslash>S<Bslash>+<Bar>', 'b')<CR>
                                                >
                                                > Is there a way to prevent this search string from appearing in the
                                                > search history? This is really not useful to remember while always
                                                > available through my mapping. It does push down the real search
                                                > strings
                                                > that I have used before.
                                                >
                                                > I could of course save the value of the @/ register, do the search and
                                                > restore @/ from the saved value. That is already a bit better, but
                                                > still
                                                > the <Bar><Bslash>S<Bslash>+<Bar> pattern is then the next historic
                                                > entry. I'd like to simply pop it off the search stack, but do not know
                                                > how to achieve this.
                                                >
                                                > Guido.

                                                Are you sure the text passed to search() gets into history? That has not
                                                been my experience and I just verified again to confirm that it doesn't
                                                happen.

                                                --
                                                HTH,
                                                Hari

                                                >
                                                >
                                                > >
                                                >

                                                --~--~---------~--~----~------------~-------~--~----~
                                                You received this message from the "vim_use" maillist.
                                                For more information, visit http://www.vim.org/maillist.php
                                                -~----------~----~----~----~------~----~------~--~---
                                              • A.Politz
                                                ... Doesn t happen on this site as well. Though the question is interesting in case of e.g scripted :s commands. However you can use buildin functions to
                                                Message 23 of 25 , Oct 28 5:24 PM
                                                  Hari Krishna Dara wrote:

                                                  >On Sun, 28 Oct 2007 at 2:48pm, guido wrote:
                                                  >
                                                  >
                                                  >
                                                  >>I am posting this reply to the original message, in order to thank all
                                                  >>people that replied to it: Tony, Ap, Csaba, Bill.
                                                  >>It's always amazing to experience the helpfulness of the vim
                                                  >>community!
                                                  >>
                                                  >>I have now following mappings in ~/vim/ftplugin/help.vim:
                                                  >>nmap <buffer> s :call search('<Bar><Bslash>S<Bslash>+<Bar>')<CR>
                                                  >>nmap <buffer> S :call search('<Bar><Bslash>S<Bslash>+<Bar>', 'b')<CR>
                                                  >>
                                                  >>Is there a way to prevent this search string from appearing in the
                                                  >>search history? This is really not useful to remember while always
                                                  >>available through my mapping. It does push down the real search
                                                  >>strings
                                                  >>that I have used before.
                                                  >>
                                                  >>I could of course save the value of the @/ register, do the search and
                                                  >>restore @/ from the saved value. That is already a bit better, but
                                                  >>still
                                                  >>the <Bar><Bslash>S<Bslash>+<Bar> pattern is then the next historic
                                                  >>entry. I'd like to simply pop it off the search stack, but do not know
                                                  >>how to achieve this.
                                                  >>
                                                  >>Guido.
                                                  >>
                                                  >>
                                                  >
                                                  >Are you sure the text passed to search() gets into history? That has not
                                                  >been my experience and I just verified again to confirm that it doesn't
                                                  >happen.
                                                  >
                                                  >
                                                  >
                                                  Doesn't happen on this site as well. Though the question is interesting
                                                  in case of e.g scripted :s commands.
                                                  However you can use buildin functions to manipulate the various histories.
                                                  For example

                                                  call histdel("/",-1)

                                                  to delete the last searchpattern.

                                                  -ap



                                                  --
                                                  Ich hab geträumt, der Krieg wär vorbei.


                                                  --~--~---------~--~----~------------~-------~--~----~
                                                  You received this message from the "vim_use" maillist.
                                                  For more information, visit http://www.vim.org/maillist.php
                                                  -~----------~----~----~----~------~----~------~--~---
                                                • guido
                                                  ... [snip] ... Apparently, it was left in the history from earlier experiments where I used the / key, rather than the call search() approach. I switched
                                                  Message 24 of 25 , Oct 29 1:20 AM
                                                    On Oct 29, 12:30 am, Hari Krishna Dara <hari....@...> wrote:
                                                    >
                                                    [snip]
                                                    > Are you sure the text passed to search() gets into history? That has
                                                    > not been my experience and I just verified again to confirm that it
                                                    > doesn't happen.
                                                    Apparently, it was left in the history from earlier experiments where
                                                    I
                                                    used the '/' key, rather than the 'call search()' approach. I switched
                                                    to the latter to avoid inclusion in the '/' history, but was misled by
                                                    the fact that it was already in there.

                                                    Thanks.

                                                    Guido


                                                    --~--~---------~--~----~------------~-------~--~----~
                                                    You received this message from the "vim_use" maillist.
                                                    For more information, visit http://www.vim.org/maillist.php
                                                    -~----------~----~----~----~------~----~------~--~---
                                                  • guido
                                                    ... [snip] ... Not here either: it was left over from earlier uses of the / key. Sorry for the noise. ... Didn t know that one! Thanks! Guido
                                                    Message 25 of 25 , Oct 29 1:41 AM
                                                      On Oct 29, 1:24 am, "A.Politz" <poli...@...> wrote:
                                                      > Hari Krishna Dara wrote:
                                                      > >On Sun, 28 Oct 2007 at 2:48pm, guido wrote:
                                                      [snip]
                                                      > >>Is there a way to prevent this search string from appearing in the
                                                      > >>search history? This is really not useful to remember while always
                                                      > >>available through my mapping. It does push down the real search
                                                      > >>strings that I have used before.
                                                      >
                                                      > >>I could of course save the value of the @/ register, do the search
                                                      > >>and restore @/ from the saved value. That is already a bit better,
                                                      > >>but still the <Bar><Bslash>S<Bslash>+<Bar> pattern is then
                                                      > >>the next historic entry. I'd like to simply pop it off the search stack,
                                                      > >>but do not know how to achieve this.
                                                      >
                                                      > >Are you sure the text passed to search() gets into history? That has
                                                      > >not been my experience and I just verified again to confirm that it
                                                      > >doesn't happen.
                                                      >
                                                      > Doesn't happen on this site as well.

                                                      Not here either: it was left over from earlier uses of the '/' key.
                                                      Sorry for the noise.

                                                      > However you can use buildin functions to manipulate the various
                                                      > histories. For example
                                                      >
                                                      > call histdel("/",-1)
                                                      >
                                                      Didn't know that one!

                                                      Thanks!

                                                      Guido


                                                      --~--~---------~--~----~------------~-------~--~----~
                                                      You received this message from the "vim_use" maillist.
                                                      For more information, visit http://www.vim.org/maillist.php
                                                      -~----------~----~----~----~------~----~------~--~---
                                                    Your message has been successfully submitted and would be delivered to recipients shortly.