source: myself
Useful Keyboard shortcuts in Vim
Find next: Shift+3(which is #)
Find previous: Shift+8(which is *)
source: http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29
Useful Keyboard shortcuts in Vim
Find next: Shift+3(which is #)
Find previous: Shift+8(which is *)
source: http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29
Keyboard shortcuts[edit]
The following shortcuts work when using default (Emacs) key bindings. Vi-bindings can be enabled by running
set -o vi
.[23]
Note: For shortcuts involving ⎇ Alt, you may be able to use ⎋ Esc instead.
Note: Sometimes, you must use ⎋ Esc instead of ⎇ Alt, because the ⎇ Alt shortcut conflicts with another shortcut. For example, in Trisquel 5.0 (a distribution of Linux), pressing ⎇ Alt+f will not move the cursor forward one word, but will activate "File" in the menu of the terminal window.
See also: Readline
- Tab ↹ : Autocompletes from the cursor position.
- ^ Ctrl+a : Moves the cursor to the line start (equivalent to the key ⇱ Home).
- ^ Ctrl+b : Moves the cursor back one character (equivalent to the key ←).
- ^ Ctrl+c : Sends the signal SIGINT to the current task, which aborts and closes it.
- ^ Ctrl+d
- ^ Ctrl+e : (end) moves the cursor to the line end (equivalent to the key ⇲ End).
- ^ Ctrl+f : Moves the cursor forward one character (equivalent to the key →).
- ^ Ctrl+g : Abort the research and restore the original line.
- ^ Ctrl+h : Deletes the previous character (same as backspace).
- ^ Ctrl+i : Equivalent to the tab key.
- ^ Ctrl+j : Equivalent to the enter key.
- ^ Ctrl+k : Clears the line content after the cursor and copies it into the clipboard.
- ^ Ctrl+l : Clears the screen content (equivalent to the command
clear
). - ^ Ctrl+n : (next) recalls the next command (equivalent to the key ↓).
- ^ Ctrl+o : Executes the found command from history, and fetch the next line relative to the current line from the history for editing.
- ^ Ctrl+p : (previous) recalls the prior command (equivalent to the key ↑).
- ^ Ctrl+r : (research) recalls the last command including the specified character(s). A second ^ Ctrl+r recalls the next anterior command which corresponds to the research
- ^ Ctrl+s : Go back to the next more recent command of the research (beware to not execute it from a terminal because this command also launches its XOFF). If you changed that XOFF setting, use^ Ctrl+q to return.
- ^ Ctrl+t : Transpose the previous two characters.
- esc+t : Swap the last two words before the cursor
- ^ Ctrl+u : Clears the line content before the cursor and copies it into the clipboard.
- ^ Ctrl+v : If the next input is also a control sequence, type it literally (e. g. * ^ Ctrl+v ^ Ctrl+h types "^H", a literal backspace.)
- ^ Ctrl+w : Clears the word before the cursor and copies it into the clipboard.
- ⎇ Alt+d : Cuts the word after the cursor.
- ^ Ctrl+x ^ Ctrl+e : Edits the current line in the $EDITOR program, or vi if undefined.
- ^ Ctrl+x ^ Ctrl+r : Read in the contents of the inputrc file, and incorporate any bindings or variable assignments found there.
- ^ Ctrl+x ^ Ctrl+u : Incremental undo, separately remembered for each line.
- ^ Ctrl+x ^ Ctrl+v : Display version information about the current instance of bash.
- ^ Ctrl+x ^ Ctrl+x : Alternates the cursor with its old position. (C-x, because x has a crossing shape).
- ^ Ctrl+y : (yank) adds the clipboard content from the cursor position.
- ^ Ctrl+z : Sends the signal SIGTSTP to the current task, which suspends it. To execute it in background one can enter
bg
. To bring it back from background or suspensionfg ['process name or job id']
(foreground) can be issued. - ^ Ctrl+_ : Incremental undo, separately remembered for each line.
- ⎇ Alt+b : (backward) moves the cursor backward one word.
- ⎇ Alt+c : Capitalizes the character under the cursor and moves to the end of the word.
- ⎇ Alt+f : (forward) moves the cursor forward one word.
- ⎇ Alt+r : Cancels the changes and puts back the line as it was in the history.
- ⎇ Alt+u : Capitalizes every character from the cursor's position to the end of the current word.
- ⎇ Alt+l : Lowers the case of every character from the cursor's position to the end of the current word.
- ⎇ Alt+. : Insert the last argument to the previous command (the last word of the previous history entry).
You can also highlight text and use Ctrl-Shift-c to copy, and Ctrl-Shift v to paste (at least in GNOME Terminal in Ubuntu).
source: http://stackoverflow.com/questions/657130/fastest-ways-to-move-the-cursor-on-a-terminal-command-line
Bash is very common shell, for example. It uses Readline library to implement command line input. And so to say, it is very convenient to know Readline bindings since it is used not only in bash. For example, gdb also uses Readline to process input.
In Readline documentation you can find all navigation related bindings (and more):http://www.gnu.org/software/bash/manual/bash.html#Readline-Interaction
Short copy-paste if the link above goes down:
Bare Essentials
- C-b Move back one character.
- C-f Move forward one character.
- [DEL] or [Backspace] Delete the character to the left of the cursor.
- C-d Delete the character underneath the cursor.
- C-_ or C-x C-u Undo the last editing command. You can undo all the way back to an empty line.
Movement
- C-a Move to the start of the line.
- C-e Move to the end of the line.
- M-f Move forward a word, where a word is composed of letters and digits.
- M-b Move backward a word.
- C-l Clear the screen, reprinting the current line at the top.
Kill and yank
- C-k Kill the text from the current cursor position to the end of the line.
- M-d Kill from the cursor to the end of the current word, or, if between words, to the end of the next word. Word boundaries are the same as those used by M-f.
- M-[DEL] Kill from the cursor the start of the current word, or, if between words, to the start of the previous word. Word boundaries are the same as those used by M-b.
- C-w Kill from the cursor to the previous whitespace. This is different than M- because the word boundaries differ.
- C-y Yank the most recently killed text back into the buffer at the cursor.
- M-y Rotate the kill-ring, and yank the new top. You can only do this if the prior command is C-y or M-y.
M is Meta key. For Max OS X Terminal you can enable "Use option as meta key" in Settings/Keyboard for that. For Linux its more complicated.
Update
Also note, that Readline can operate in two modes:
- emacs mode (which is the default)
- vi mode
To switch Bash to use vi mode:
$ set -o vi
Personaly I prefer vi mode since I use vim for text editing.
In the standard Ubuntu terminal, Meta (M) is Alt+Shift, unless you disable the menu access keyboard shortcuts in which case it is just Alt. (THIS IS IT!!!)
댓글
댓글 쓰기