82
submitted 5 days ago by [email protected] to c/[email protected]
top 12 comments
sorted by: hot top new old
[-] [email protected] 2 points 5 days ago* (last edited 5 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] 8 points 5 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] 2 points 5 days ago

I am aware, explained more in my other comment

[-] [email protected] 5 points 5 days ago

ctrl+a and ctrl+e are from Emacs.

[-] [email protected] 3 points 4 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.

[-] [email protected] 3 points 3 days ago* (last edited 3 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] 2 points 2 days 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] 2 points 5 days ago

Yes but OP is using vi bindings for line navigation.

[-] [email protected] 2 points 4 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] 1 points 4 days ago

Ctrl a and e are same as bash

[-] [email protected] 1 points 5 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] 0 points 5 days ago* (last edited 5 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.

this post was submitted on 07 Jun 2025
82 points (97.7% liked)

Linux

55149 readers
993 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS