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

abbreviation difficulty

Expand Messages
  • jkilbour@pol.net
    I added this to my _vimrc: abbr bbb BEGIN{FS= | } but something is going on with the quotes and bar; when I type bbb , I get BEGIN{FS= what will help?
    Message 1 of 10 , Dec 23, 2005
    • 0 Attachment
      I added this to my _vimrc:
      abbr bbb BEGIN{FS="|"}

      but something is going on with the quotes and bar; when I type
      "bbb ",
      I get
      BEGIN{FS="

      what will help?
    • Gary Johnson
      ... Take a look at ... You will need to quote the bar with one or more Ctrl-Vs. I m not sure how many will be needed to define that abbreviation in your
      Message 2 of 10 , Dec 23, 2005
      • 0 Attachment
        On 2005-12-23, jkilbour@... wrote:
        > I added this to my _vimrc:
        > abbr bbb BEGIN{FS="|"}
        >
        > but something is going on with the quotes and bar; when I type
        > "bbb ",
        > I get
        > BEGIN{FS="
        >
        > what will help?

        Take a look at

        :help using_CTRL-V

        You will need to quote the bar with one or more Ctrl-Vs. I'm not
        sure how many will be needed to define that abbreviation in your
        _vimrc. I think you'll need only one, so that your abbreviation
        will look like this.

        abbr bbb BEGIN{FS="^V|"}

        To enter that one Ctrl-V, you'll need to type two of them.

        HTH,
        Gary

        --
        Gary Johnson | Agilent Technologies
        garyjohn@... | Wireless Division
        | Spokane, Washington, USA
      • A. J. Mechelynck
        ... The :abbrev command sees the bar as a separator from a following ex-command; after that anything starting with a double quote is a comment. Try ... This
        Message 3 of 10 , Dec 23, 2005
        • 0 Attachment
          jkilbour@... wrote:
          > I added this to my _vimrc:
          > abbr bbb BEGIN{FS="|"}
          >
          > but something is going on with the quotes and bar; when I type
          > "bbb ",
          > I get
          > BEGIN{FS="
          >
          > what will help?
          >
          >
          >
          >
          >

          The :abbrev command sees the bar as a separator from a following
          ex-command; after that anything starting with a double quote is a comment.

          Try
          :abbr bbb BEGIN{FS="<Bar>"}

          This assumes that you don't have < in 'cpoptions', which is the default
          in 'nocompatible' mode.


          HTH,
          Tony.
        • jkilbour@pol.net
          Thanks. Every time I type ^V (the actual control character plus a v )into my _vimrc file, the contents of my clipboard shows there. WHen I use , teh
          Message 4 of 10 , Dec 23, 2005
          • 0 Attachment
            Thanks.
            Every time I type ^V (the actual control character plus a "v")into my
            _vimrc file, the contents of my clipboard shows there. WHen I use <c-v>,
            teh contents of my clipboard shows up in the document where the
            abbreviation appears. I treid commenting out
            "source $VIMRUNTIME/mswin.vim
            "behave mswin
            but that did not help.

            > On 2005-12-23, jkilbour@... wrote:
            >> I added this to my _vimrc:
            >> abbr bbb BEGIN{FS="|"}
            >>
            >> but something is going on with the quotes and bar; when I type
            >> "bbb ",
            >> I get
            >> BEGIN{FS="
            >>
            >> what will help?
            >
            > Take a look at
            >
            > :help using_CTRL-V
            >
            > You will need to quote the bar with one or more Ctrl-Vs. I'm not sure
            > how many will be needed to define that abbreviation in your
            > _vimrc. I think you'll need only one, so that your abbreviation
            > will look like this.
            >
            > abbr bbb BEGIN{FS="^V|"}
            >
            > To enter that one Ctrl-V, you'll need to type two of them.
            >
            > HTH,
            > Gary
            >
            > --
            > Gary Johnson | Agilent Technologies
            > garyjohn@... | Wireless Division
            > | Spokane, Washington, USA
          • Gary Johnson
            ... That s because you re running on Windows and your _vimrc probably sources mswin.vim, which causes Ctrl-V to perform the standard Windows paste operation.
            Message 5 of 10 , Dec 23, 2005
            • 0 Attachment
              On 2005-12-23, jkilbour@... wrote:
              > Thanks.
              > Every time I type ^V (the actual control character plus a "v")into my
              > _vimrc file, the contents of my clipboard shows there. WHen I use <c-v>,
              > teh contents of my clipboard shows up in the document where the
              > abbreviation appears. I treid commenting out
              > "source $VIMRUNTIME/mswin.vim
              > "behave mswin
              > but that did not help.

              That's because you're running on Windows and your _vimrc probably
              sources mswin.vim, which causes Ctrl-V to perform the standard
              Windows paste operation. See

              :help mswin.vim

              You can either edit your _vimrc to not source that file, or you can
              used Ctrl-Q in place of Ctrl-V. See

              :help i_CTRL-V

              However, I think Tony's solution is better: just use <Bar> instead
              of | in your abbreviation. Using printable ASCII characters like
              that in abbreviations is much easier than messing with control
              characters.

              Gary

              --
              Gary Johnson | Agilent Technologies
              garyjohn@... | Wireless Division
              | Spokane, Washington, USA
            • Mark Woodward
              ... Are you expecting the cursor to be at the bar ( | ) when the abbreviation triggers like other windows editors? If so Vim doesn t work like that. Try: iab
              Message 6 of 10 , Dec 28, 2005
              • 0 Attachment
                jkilbour@... said the following on 24/12/2005 6:54 AM:

                >I added this to my _vimrc:
                >abbr bbb BEGIN{FS="|"}
                >
                >but something is going on with the quotes and bar; when I type
                >"bbb ",
                >I get
                >BEGIN{FS="
                >
                >what will help?
                >
                >
                >
                Are you expecting the cursor to be at the bar ("|") when the
                abbreviation triggers like other windows editors? If so Vim doesn't work
                like that. Try:
                iab bbb BEGIN{FS=""}<left><left>
                hitting the space bar gives BEGIN{FS=" |"}
                which probably isn't what you want (extra space).
                Hitting Ctl-] gives BEGIN{FS="|"}

                --
                Mark
              • Gerald Lai
                ... If you want a literal bar instead, do ... -- Gerald
                Message 7 of 10 , Dec 28, 2005
                • 0 Attachment
                  On Thu, 29 Dec 2005, Mark Woodward wrote:

                  > jkilbour@... said the following on 24/12/2005 6:54 AM:
                  >
                  >> I added this to my _vimrc:
                  >> abbr bbb BEGIN{FS="|"}
                  >>
                  >> but something is going on with the quotes and bar; when I type
                  >> "bbb ",
                  >> I get
                  >> BEGIN{FS="
                  >>
                  >> what will help?
                  >>
                  >>
                  > Are you expecting the cursor to be at the bar ("|") when the abbreviation
                  > triggers like other windows editors? If so Vim doesn't work like that. Try:
                  > iab bbb BEGIN{FS=""}<left><left>
                  > hitting the space bar gives BEGIN{FS=" |"}
                  > which probably isn't what you want (extra space).
                  > Hitting Ctl-] gives BEGIN{FS="|"}

                  If you want a literal bar instead, do

                  :abbr bbb BEGIN{FS="<Bar>"}

                  --
                  Gerald
                • jkilbour@pol.net
                  ... However, it puts an extra space at the end. I tried making it a map from normal mode, which I think is really what I want: nnoremap bbb
                  Message 8 of 10 , Dec 28, 2005
                  • 0 Attachment
                    > jkilbour@... said the following on 24/12/2005 6:54 AM:
                    >
                    >>I added this to my _vimrc:
                    >>abbr bbb BEGIN{FS="|"}
                    >>
                    >>but something is going on with the quotes and bar; when I type
                    >>"bbb ",
                    >>I get
                    >>BEGIN{FS="
                    >>
                    >>what will help?
                    >>
                    >>
                    >>
                    > Are you expecting the cursor to be at the bar ("|") when the
                    > abbreviation triggers like other windows editors? If so Vim doesn't work
                    > like that. Try:
                    > iab bbb BEGIN{FS=""}<left><left>
                    > hitting the space bar gives BEGIN{FS=" |"}
                    > which probably isn't what you want (extra space).
                    > Hitting Ctl-] gives BEGIN{FS="|"}
                    >
                    > --
                    > Mark


                    This is working almost perfectly:
                    :abbr bbb BEGIN{FS="<Bar>"}

                    However, it puts an extra space at the end.

                    I tried making it a map from normal mode, which I think is really what I
                    want:
                    nnoremap bbb iBEGIN{FS="<Bar>"}<esc>
                    but that didn't work. How can I make a map/abbr to this in normal mode,
                    instead of in insert mode?

                    Thanks.
                  • Gerald Lai
                    ... How many spaces after } is your cursor at after typing bbb ? 1. If it is 2 spaces, then you have an accidental trailing space at the end of :abbr
                    Message 9 of 10 , Dec 29, 2005
                    • 0 Attachment
                      On Thu, 29 Dec 2005, jkilbour@... wrote:

                      >
                      >
                      >> jkilbour@... said the following on 24/12/2005 6:54 AM:
                      >>
                      >>> I added this to my _vimrc:
                      >>> abbr bbb BEGIN{FS="|"}
                      >>>
                      >>> but something is going on with the quotes and bar; when I type
                      >>> "bbb ",
                      >>> I get
                      >>> BEGIN{FS="
                      >>>
                      >>> what will help?
                      >>>
                      >>>
                      >>>
                      >> Are you expecting the cursor to be at the bar ("|") when the
                      >> abbreviation triggers like other windows editors? If so Vim doesn't work
                      >> like that. Try:
                      >> iab bbb BEGIN{FS=""}<left><left>
                      >> hitting the space bar gives BEGIN{FS=" |"}
                      >> which probably isn't what you want (extra space).
                      >> Hitting Ctl-] gives BEGIN{FS="|"}
                      >>
                      >> --
                      >> Mark
                      >
                      >
                      > This is working almost perfectly:
                      > :abbr bbb BEGIN{FS="<Bar>"}
                      >
                      > However, it puts an extra space at the end.
                      >
                      > I tried making it a map from normal mode, which I think is really what I
                      > want:
                      > nnoremap bbb iBEGIN{FS="<Bar>"}<esc>
                      > but that didn't work. How can I make a map/abbr to this in normal mode,
                      > instead of in insert mode?
                      >
                      > Thanks.
                      >
                      >

                      How many spaces after } is your cursor at after typing "bbb<Space>"?

                      1. If it is 2 spaces, then you have an accidental trailing space at
                      the end of :abbr bbb BEGIN{FS="<Bar>"}<Space>

                      2. If it is 1 space, then that <Space> came from when you typed
                      "bbb<Space>". You can try typing, in Insert mode, "bbb<Esc>".

                      Judging from your next email with _vimrc, you're probably in situation
                      2.
                      --
                      Gerald
                    • Jürgen Krämer
                      Hi, ... there is a little helper function described below :help abbreviation func Eatchar(pat) let c = nr2char(getchar()) return (c =~ a:pat) ? : c
                      Message 10 of 10 , Jan 2, 2006
                      • 0 Attachment
                        Hi,

                        jkilbour@... schrieb:
                        >
                        >> jkilbour@... said the following on 24/12/2005 6:54 AM:
                        >>
                        >>> I added this to my _vimrc:
                        >>> abbr bbb BEGIN{FS="|"}
                        >>>
                        >>> but something is going on with the quotes and bar; when I type
                        >>> "bbb ",
                        >>> I get
                        >>> BEGIN{FS="
                        >>>
                        >>> what will help?
                        >>>
                        >>>
                        >>>
                        >> Are you expecting the cursor to be at the bar ("|") when the
                        >> abbreviation triggers like other windows editors? If so Vim doesn't work
                        >> like that. Try:
                        >> iab bbb BEGIN{FS=""}<left><left>
                        >> hitting the space bar gives BEGIN{FS=" |"}
                        >> which probably isn't what you want (extra space).
                        >> Hitting Ctl-] gives BEGIN{FS="|"}
                        >>
                        >> --
                        >> Mark
                        >
                        >
                        > This is working almost perfectly:
                        > :abbr bbb BEGIN{FS="<Bar>"}
                        >
                        > However, it puts an extra space at the end.

                        there is a little helper function described below ":help abbreviation"

                        func Eatchar(pat)
                        let c = nr2char(getchar())
                        return (c =~ a:pat) ? '' : c
                        endfunc

                        You can use it to discard the white space that toggled the expansion of
                        the abbreviation by calling it through the special register "=

                        iabbr <silent> bbb BEGIN{FS="<Bar>"}<C-R>=Eatchar('\s')<CR>

                        Regards,
                        Jürgen

                        --
                        Jürgen Krämer Softwareentwicklung
                        HABEL GmbH & Co. KG mailto:jkr@...
                        Hinteres Öschle 2 Tel: +49 / 74 61 / 93 53 - 15
                        78604 Rietheim-Weilheim Fax: +49 / 74 61 / 93 53 - 99
                      Your message has been successfully submitted and would be delivered to recipients shortly.