It's just mentioned a shortcut for and its usage is supposed to be obvious, but it isn't obvious to me. How do I even tell I "marked" something? Why would I mark something? Does this thing have a scope? Does it ever expire? And do I get a bash warning when/where it did? And above all, cool, I "set mark". What now?

So, what exactly is this mark that I can set and what would I use it for?

  • What happened to my comments and is this acceptable on stackexchange?! – argle Feb 11 '18 at 19:14
  • By "comments" do you mean the parts of your question that have been edited out? Take a look at the edit history for your question for an answer to that. (You can find it on the link just above these comments. Currently it reads edited 6 hours ago but obviously that will change with time. Personally I think your original question would have been closed as "Primarily opinion-based" whereas the edited version is a straightforward question with a presumably straightforward answer. – roaima Feb 12 '18 at 0:22
  • @roaima I agree that "comments" can (only) be understood that way and I appreciate your attentive explanation, often so needed. I meant actual comments. A while after the editing, the five comments got deleted, including not obsoleted ones (and anyway I thought moderators deleted abuse and let users do their own other editing/deleting). It's actually surprising that you can't see the deleted comments or any mention of the deletion in some log accessible at your 34k+ reputation level. Does this happen? And is there a way for me to recover my messages (to save them locally)? – argle Feb 12 '18 at 8:28
  • I can't see deleted comments. I have no idea whether or not moderators can see deleted comments. This would be a reasonable question to take to meta – roaima Feb 12 '18 at 11:36

Strictly speaking, set-mark isn't a bash command, it's a readline command. It's used to set a "mark" on a specific location in the command line you are currently editing.

That mark can then be used in other readline editing operations.

Full documentation for readline may not be installed by default. Depending on your distribution it may be in a separate package, with a name like readline-doc, in GNU Info file format (requires, e.g., info or pinfo to view). It is also available on the web at https://tiswww.case.edu/php/chet/readline/rltop.html

It is also documented in the bash man page, and in the man pages of several other GNU programs that use readline. Run man bash and search for ^READLINE.

From man bash:

Readline Command Names

The following is a list of the names of the commands and the default key sequences to which they are bound. Command names without an accompanying key sequence are unbound by default. In the following descriptions, point refers to the current cursor position, and mark refers to a cursor position saved by the set-mark command. The text between the point and mark is referred to as the region.

Note that readline commands are for both interactive use (i.e. while editing a command line) and programmatic use (e.g. in your ~/.inputrc). That is why some of the commands have options/arguments.

BTW, there aren't many readline commands that make any use of marks or regions (The point is used frequently, by many readline commands). They are:

Two with default key-bindings:

set-mark (C-@, M-<space>)

Set the mark to the point. If a numeric argument is supplied, the mark is set to that position.

exchange-point-and-mark (C-x C-x)

Swap the point with the mark. The current cursor position is set to the saved position, and the old cursor position is saved as the mark.

So you can mark the current cursor position with Ctrl-@ or Meta-<space>and swap the mark for the current cursor position by typing Ctrl-x twice. i.e. useful for jumping back and forth between two positions in the line.

and two without default key-bindings:


Kill the text in the current region.


Copy the text in the region to the kill buffer.

To use either of these while interactively editing on the command line, you'd have to bind them to a key.

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.