5 ms·
C-a : beginning line, C-e end line, alt+f forward word (unless system shortcut for file menu), alt+b back word, C-k kill line, C-b back char, C-f forward char.
by SDGT 13y ago
C-a : beginning line, C-e end line, alt+f forward word (unless system shortcut for file menu), alt+b back word, C-k kill line, C-b back char, C-f forward char.
At least in my current setup, C-w yank and C-y paste works as well.
Immensely helpful. Sometimes at+left/right does forward/ back word depending on the terminal emu.
Note most of these keystrokes are valid in nano as well.
- pavanky 13y agoMore: - C-u to kill (cut) from current location to beginning of the line - C-k to kill (cut) from current location to end of line - C-w to kill (cut) from current location to beginning of word - C-y to paste (copied / cut) lines - C-l to clear screen (I use the shit out of this) - Ctrl + shift + '-' (holding ctrl, shift, minus at the same time), for undo. That is it. EDIT: Damn it, I didn't realize I was saying a bunch of the same things as you did. EDIT2 Thanks oinksoft for clearing up C-u and C-w.
- oinksoft 13y agoJust wanted to note: C-u kills from cursor to start of line. C-w kills from cursor to start of previous word. M-d is its friendly forward sibling.
- pavanky 13y agoThanks! fixed. I never noticed C-u was from cursor. I tend to use it mostly from the end of the line.
- oinksoft 13y agoAnd that's why C-e C-u is burned into my hands :^)
- philsnow 13y agoIs it any different from C-a C-k ? Both seem to stuff things into the kill ring (or whatever it's called in bash). I guess lots of people leave C-a as the default escape key for screen.
- oinksoft 13y agoYea, there's the GNU Screen mapping conflict, and also I rarely use C-k so it's not in my muscle memory.
- philsnow 13y agoMakes sense; I use emacs in addition to just the emacs-like readline bindings, so C-u conflicts with "prefix argument". I also nest screen sessions using ^Z as the outer one's escape key and ^O as the inner one's, partly so I can use C-a / ^A.
- teddyh 13y agoNote: Ctrl-U and Ctrl-W are not from Emacs. They are instead from the same group as Ctrl-C for interrupt, Ctrl-D for End-of-File, etc; i.e. traditional Unix TTY driver keys. Run “stty -a” to see them all; the stty command can also be used to change them.
- Syssiphus 13y agoPressing ESC and then _ will insert the last argument of the last line. Repeat to go up in the history. If you go through the command history and press CTRL-o on a line it will be executed and the command on the commandline will be replaced by the next line in the history.
- oinksoft 13y agoIn Bash, you also can use the $_ variable which is the last argument of the previous command: $ stat /tmp/foobar File: `/tmp/foobar' Size: 0 Blocks: 0 IO Block: 4096 ... $ rm -v $_ removed `/tmp/foobar'
- philsnow 13y agoAlso M-. (meta-period). Keep banging on M-. to pull in the last argument of preceding commands. With a numeric prefix argument N, it grabs the Nth-from-the-end argument of the previous command, so M-3 M-. grabs the 3rd-from-last argument from the previous command.
- ivanhoe 13y agoalso alt + backspace, works similar to ctrl + w, but word is defined as only alphanumerics. Very useful when deleting parts of the long file paths because it will stop on / character (unlike C-w that deletes the whole path)
- deleted 13y ago[deleted]
- RBerenguel 13y agoAlso, most emacs keybindings (C-u and C-w don't, but C-k, e, a and y do, at the very least) work in all Cocoa text fields. This (in general) means you have two copy buffers: the normal, system wide Cmd-C (or X), Cmd-V and the "Cocoa wide" C-k C-y buffer
- jakobe 13y agoMy favorite undocumented keybinding: C-t (transpose) for sloppy typers like me.
- RBerenguel 13y agoDidn't know C-t worked in Cocoa's. Thanks for pointing it out, always useful!
- ajlburke 13y agoThe basic emacs shortcuts even work on iOS, if you're using a Bluetooth keyboard. Now the muscle memory works everywhere.
- RBerenguel 13y agoRight! Weirdly enough, C-k kills a word in (at least) the Editorial writing app in iOS7 (only writing app where I have tried since upgrading my iPad)
- tvon 13y agohttp://tiswww.case.edu/php/chet/readline/readline.html http://tiswww.case.edu/php/chet/readline/readline.html These work in most GUI inputs as well.
- Someone 13y agoMac OS X uses libedit (http://thrysoee.dk/editline/ http://thrysoee.dk/editline/, http://www.opensource.apple.com/source/libedit/libedit-39/ http://www.opensource.apple.com/source/libedit/libedit-39/), not GNU readline. But yes, the keybindings work in Cocoa text controls, too, for example in TextEdit, in the Safari URL/search control, etc.
- lazerwalker 13y agoIt's worth noting that that the C-w/C-k/C-y yank ring is a distinct buffer from the system Cmd+X/C/V pasteboard. That way, you can have two different things on your clipboard without having to use a fancy clipboard manager. (Or, alternatively, you can be confused why the thing you're pasting isn't the thing you thought you copied last.)