• @[email protected]
    link
    fedilink
    2
    edit-2
    4 days ago

    Now I have four ways to get to the begining and end of a command line. I can press Escape,^ or Ctrl+a for the begining of the line, and Escape,$ or Ctrl+e for the end of the line.

    Bit suss on the ctrl-A start of line, because vim binding is A for append which is end of line.

    • @[email protected]
      link
      fedilink
      33 days ago

      Control-A and E should work in insert mode. That’s why OP mentions pressing escape before issuing the normal mode ^ and $ commands.

      In insert mode, some or most of the EMacs-style shortcuts work.

    • @[email protected]
      link
      fedilink
      84 days ago

      Ctrl +a and Ctrl +e for beginning and end of line are from Emacs.

      GNU Readline is what provides them in the bash. There’s a bunch of shortcuts worth learning in there!

      Most distributions I’ve tried use Emacs as the default shell binding style, some of the bindings are even available in things like appliance cli’s like Cisco IOS and clones.

      Bash supports vi mode too, you just have to switch to it.

      set -o vi
      

      ZSH uses zle (ZSH Line Editor) instead of Readline, but I assume the Emacs style bindings have been copied over to zle for muscle memory portability. You can switch the keymap in zle,

      bindkey -v
      

      or set your own!

      • @[email protected]
        link
        fedilink
        32 days ago

        Is there an emacs key to ‘delete this entire word’?

        like if I’m using ls to look for a file, then I want to cat a file, I press up to get the previous command, ctrl+a to go to the beginning of the line and then spam d to delete letters. It’s be much better if there was a ‘delete until whitespace’ button.

        • pine
          link
          fedilink
          3
          edit-2
          2 days ago

          M-d, aka alt+d

          Generally in emacs ctrl+whatever operates on characters, while alt+whatever operates on words. For example, you can do ctrl+f/b to go forward/backword a character, and alt+f/b to go forward/backward a word.

          • @[email protected]
            link
            fedilink
            21 day ago

            Oh yeah, that’s way better. Thanks!

            I’m using zsh and trying the emacs mode, that alt operates on words is the secret sauce I was looking for.

    • @[email protected]
      link
      fedilink
      English
      14 days ago

      Maybe I’m misunderstanding, but the commands would apply within the zsh, which is a bash alternative, not within the programmes running themselves?

      Or are you saying its sus because its illogical/confusing to have opposite uses for tgebsame shirt cut? I can see that as people using a terminal and launching vim would constantly be working against “muscle memory” each time they switch which would be annoying! Being familiar with keyboard shortcuts is what can make terminal based workflows so fast.

      • @[email protected]
        link
        fedilink
        0
        edit-2
        4 days ago

        It was a little strange in the “line movement” part they were talking about setting vim navigation on the cmd line and then putting Emacs style as aliases, of which I said it’s a bit suss as it’s too close to vim append.