Like jumping to the end of a line is Ctrl+E, where E can be thought of as end, why does it jump to the start using A?

  • 1
    You can think of "A" for "Anfang" – Anthon Jan 18 '15 at 8:49
  • Or "A" is the first letter in alpabet – Costas Jan 18 '15 at 10:29
  • Please note that that in emacs (and in bash as well) you can jump to beginning/end of the line also with Home/End keys by default. – jimmij Jan 18 '15 at 10:36

There are two sides to the question, the technical side and the historical side.

The technical answer is because bash uses GNU Readline. In readline Control-a is bound to the function beginning-of-line, you can show this with:

$ bind -q beginning-of-line
beginning-of-line can be invoked via "\C-a", "\M-OH", "\M-[1~", "\M-[7~", "\M-[H".

where \C-a means "Control-a". bind -p will show all bindings (be careful using bind, it's easy to break your keyboard if you accidentally provide additional options or arguments).

Some of the above bindings are added by default, others I have added (via .inputrc) for various terminals I have used. Since bash-2.0, if the terminal termcap contains the capabilities kh, and kH then Home and End will be set to beginning-of-line and end-of-line. Both bash and readline are developed by Chet Ramey, an Emacs user and also the developer of ce an Emacs clone.

(Please note, this endeavours to summarise many years of history from many decades ago, and glosses over some details.)

Now, why is it Control-a in particular? Readline uses by default Emacs-like bindings. Control-a in GNU Emacs invokes move-beginning-of-line, what we consider to be the "home" function now.

Stallman and Steel's original EMACS was inspired by Fred Wright's E editor (an early WYSIWYG editor) and TECO (a cryptic modal editor/language) -- EMACS was a set of macros for TECO. See Essential E [PDF] (from SAIL, 1980). E however used Control-Form for "beginning of line", this was on the "DataDisc" keyboard which had a Control key, and a Form key. The space-cadet keyboard of the time (lacking a Home key by the way, though it had an End) is commonly blamed for the Emacs keyboard interface.

One of the desirable features of EMACS was its use of TECO's Control-R "real-time" line editing mode (TECO predates CRT/keyboard terminals), you can see the key bindings on page 6 of the MIT AI Lab 1978 ITS Introduction to the EMACS editor [scanned PDF], where ┌ is used to denote Control. In this mode, the key bindings were all control sequences, largely mnemonic: Control-E End of this line, Control-P move to previous line, Control-N move to next line, Control-B backward one character, and not least Control-A move to beginning of this line, Costas' suggestion of "first letter of the alphabet" for this is as good as any.

(A similar key-binding is in the tvlib macro package which aimed to make EMACS behave like the TVEDIT editor, binding control A and E to backward and forward sentence, but used different sequences for beginning and end of line.)

The Control-A/Control-E bindings in "^R mode" were implemented directly in the ITS TECO (1983, version 1208, see the _teco_.tgz archive at the nocrew PDP10/ITS site, or on Github ), though I cannot determine more accurately when they first appeared, and the TECO source doesn't indicate why any particular bindings were chosen. The 1978 MIT EMACS document above implies that in 1978 EMACS did not use TECO native Control-A/Control-E, it's possible that the scrlin macro package (screen line) implemented these.

To recap:

  • bash uses readline
  • readline key bindings follow Emacs/EMACS
  • the original EMACS was created with TECO, inheriting many features
  • TECO's interactive mode macros used (mostly) mnemonic control key bindings, and "start of line" ended up assigned to Control-A

See also:


Because Richard Stallman likes Emacs.

Ctrl+a is jumping to the start of the line in Emacs, and libreadline uses the same key bindings as Emacs. Bash uses libreadline.

  • 2
    Note also that you can do set -o vi, or echo 'set editing-mode vi' >> ~/.inputrc, to get Vim keybindings! – wchargin Jan 18 '15 at 15:42
  • Why are people giving this answer points? The question was why ctrl+a was chosen as the command to go to the start of the line, not what the command is. – wurtel Jan 19 '15 at 8:47
  • @Wurtel The answer is in the first sentence, see "history of Gnu". – Jasen Jan 19 '15 at 9:15
  • 3
    Sorry, but Because Richard Stallman likes Emacs. does not tell me why ctrl-a takes me to the start of the line. Why not ctrl-s, or ctrl-x, or whatever?! – wurtel Jan 19 '15 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.