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

vi commands in bash

Expand Messages
  • Robert Cussons
    Hi all, I just found out about putting: set -o vi in my .bashrc to get vim style command line editing in bash, I have the feeling that this could be very
    Message 1 of 8 , Dec 1, 2005
    • 0 Attachment
      Hi all,

      I just found out about putting: set -o vi in my .bashrc to get vim
      style command line editing in bash, I have the feeling that this could
      be very useful, but it doesn't work exactly how I would like it to. I
      hope it is OK to post on this list about this as I think it is a useful
      feature to users of Vim.

      The first thing is it would be good for the cursor in the command line
      to change to act like in vim. So it changes when it is in insert mode to
      a line, and a block when it is in command mode, otherwise it is
      difficult to be sure which mode you are in.

      The second is when I search back through history I would like to end up
      at the end of the line, not the start (I'm sure this can be done with a
      mapping, but I don't know how as I am no good with mappings!)

      There may be more things I want to change, but these, especially the
      first one would illuminate them!

      Many thanks,
      Rob.
    • Chris Allen
      ... Ironically, the vi key bindings are the only key binding set required of a sh-style shell by the Single Unix Specification. Equally ironically, they have
      Message 2 of 8 , Dec 1, 2005
      • 0 Attachment
        On 01/12/05, Robert Cussons <r.cussons@...> wrote:
        > I just found out about putting: set -o vi in my .bashrc to get vim
        > style command line editing in bash, I have the feeling that this could
        > be very useful, but it doesn't work exactly how I would like it to.

        Ironically, the vi key bindings are the only key binding set required
        of a sh-style shell by the Single Unix Specification. Equally
        ironically, they have a long and glorious history of being badly and
        inconsistently implemented, despite being part of the SUS. While
        there is something to be said for consistency (and I certainly try to
        use Bash as though it were vi somtimes), you will probably find, in
        the long run, that it is far more awkward and painful to use vi
        bindings than it is to accept the default Emacs-like bindings. This
        is especially true if you use different implementations of sh and even
        different versions of bash, since almost none of them will behave in
        quite the same way.

        > I hope it is OK to post on this list about this as I think it is a useful
        > feature to users of Vim.

        Undoubtedly okay, but Bash/sh/etc are completely unrelated to Vim, so
        your suggestions are likely to go unimplemented. It might be possible
        to re-bind things under Bash using Readline, but you'd probably have
        better luck posting to a Bash or Readline mailing list.

        HTH,
        Chris Allen
      • Jean-Rene David
        ... Two thoughts: - although useful on this list for informational purposes, I think requests to modify bash will be more useful on a bash-related list; - I
        Message 3 of 8 , Dec 1, 2005
        • 0 Attachment
          * Robert Cussons <r.cussons@...>:
          > I just found out about putting: set -o vi in
          > my .bashrc

          Two thoughts:

          - although useful on this list for informational
          purposes, I think requests to modify bash will
          be more useful on a bash-related list;

          - I personnally find zsh's vi-mode far better
          than bash's, and more flexible to boot. For
          example, you could do what you are asking fairly
          easily.

          But let's not get too far off-topic...

          --
          JR
        • Denio, Michael (IT)
          You may want to try zsh. I ve found the the vi mode to be superior to bash. ... NOTICE: If received in error, please destroy and notify sender. Sender does
          Message 4 of 8 , Dec 1, 2005
          • 0 Attachment
            You may want to try zsh. I've found the the vi mode to be superior to
            bash.

            > -----Original Message-----
            > From: Chris Allen [mailto:c.d.allen@...]
            > Sent: Thursday, December 01, 2005 9:42 AM
            > To: r.cussons@...
            > Cc: vim@...
            > Subject: Re: vi commands in bash
            >
            > On 01/12/05, Robert Cussons <r.cussons@...> wrote:
            > > I just found out about putting: set -o vi in my .bashrc
            > to get vim
            > > style command line editing in bash, I have the feeling that
            > this could
            > > be very useful, but it doesn't work exactly how I would like it to.
            >
            > Ironically, the vi key bindings are the only key binding set
            > required of a sh-style shell by the Single Unix
            > Specification. Equally ironically, they have a long and
            > glorious history of being badly and inconsistently
            > implemented, despite being part of the SUS. While there is
            > something to be said for consistency (and I certainly try to
            > use Bash as though it were vi somtimes), you will probably
            > find, in the long run, that it is far more awkward and
            > painful to use vi bindings than it is to accept the default
            > Emacs-like bindings. This is especially true if you use
            > different implementations of sh and even different versions
            > of bash, since almost none of them will behave in quite the same way.
            >
            > > I hope it is OK to post on this list about this as I think it is a
            > > useful feature to users of Vim.
            >
            > Undoubtedly okay, but Bash/sh/etc are completely unrelated to
            > Vim, so your suggestions are likely to go unimplemented. It
            > might be possible to re-bind things under Bash using
            > Readline, but you'd probably have better luck posting to a
            > Bash or Readline mailing list.
            >
            > HTH,
            > Chris Allen
            >
            >
            --------------------------------------------------------

            NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited.
          • Matthew Winn
            ... I ve had trouble with recent versions of Zsh and Vim on some platforms. With Zsh version 4.x.x everything would work OK until I went into Vim and then used
            Message 5 of 8 , Dec 1, 2005
            • 0 Attachment
              On Thu, Dec 01, 2005 at 10:20:40AM -0500, Denio, Michael (IT) wrote:
              > You may want to try zsh. I've found the the vi mode to be superior to
              > bash.

              I've had trouble with recent versions of Zsh and Vim on some platforms.
              With Zsh version 4.x.x everything would work OK until I went into Vim
              and then used :sh to open an interactive subshell. After I left the
              subshell the next key I pressed in Vim caused Vim to abort claiming that
              it was unable to read its input. I spent an hour or two trying to track
              the problem down but never managed to find the cause.

              Zsh version 3.1.9 works perfectly.

              --
              Matthew Winn (matthew@...)
            • Robert Cussons
              ... Hi Jean, thanks for the advice, it wasn t so much a request to modify bash, it was a request for advice on how to work around bash in its present state
              Message 6 of 8 , Dec 1, 2005
              • 0 Attachment
                Jean-Rene David wrote:

                >* Robert Cussons <r.cussons@...>:
                >
                >
                >>I just found out about putting: set -o vi in
                >>my .bashrc
                >>
                >>
                >
                >Two thoughts:
                >
                >- although useful on this list for informational
                > purposes, I think requests to modify bash will
                > be more useful on a bash-related list;
                >
                >- I personnally find zsh's vi-mode far better
                > than bash's, and more flexible to boot. For
                > example, you could do what you are asking fairly
                > easily.
                >
                >But let's not get too far off-topic...
                >
                >
                >
                Hi Jean,

                thanks for the advice, it wasn't so much a request to modify bash, it
                was a request for advice on how to work around bash in its present state
                with mappings etc. and I thought people well versed in Vim might know
                how to perform the relevant action as they might have tried to do it
                themselves. But I will try submitting to a bash related list and see if
                I have any joy.
                Rob.
              • Charles E. Campbell, Jr.
                ... Hopefully no one has received your email in error! However, how does one notify a sender that has been destroyed already? Besides, is there a preferred
                Message 7 of 8 , Dec 1, 2005
                • 0 Attachment
                  Denio, Michael (IT) wrote:

                  >You may want to try zsh. I've found the the vi mode to be superior to
                  >bash.
                  >
                  >
                  >--------------------------------------------------------
                  >
                  >NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited.
                  >
                  >
                  Hopefully no one has received your email in error! However, how does
                  one notify a sender that has been destroyed already? Besides, is there
                  a preferred method for destroying the sender? Perhaps cruise
                  missiles? Hmm, the use of what is prohibited? Did I just use
                  something? Uh oh...

                  Don't y'all just love the legal argle bargle disclaimers... at least
                  this one was short.
                  Chip Campbell
                • Mark Volkmann
                  ... Cool! But how do you do command-line completion? The tab key no longer does that when in vi mode. -- R. Mark Volkmann Partner, Object Computing, Inc.
                  Message 8 of 8 , Jan 24, 2006
                  • 0 Attachment
                    On 12/1/05, Robert Cussons <r.cussons@...> wrote:
                    > Hi all,
                    >
                    > I just found out about putting: set -o vi in my .bashrc to get vim
                    > style command line editing in bash

                    Cool! But how do you do command-line completion? The tab key no
                    longer does that when in vi mode.

                    --
                    R. Mark Volkmann
                    Partner, Object Computing, Inc.
                  Your message has been successfully submitted and would be delivered to recipients shortly.