How to select text in iterm with Shift+Arrow?
Solution 1
Follow the directions in this superuser answer which describes using the iTerm custom key bindings to map ⌥ + ⇧ + ← to select by word. Its smart to make new key mappings in a profile to test it out, rather than the main keys preference.
Suggested keybindings
iTerm: Preferences > Profiles > Keys
Click +
to add a keybinding, Click to Set
⌥ + ← | Action: Move start of selection back > Move by character
⌥ + → | Action: Move end of selection forward > Move by character
⌥ + ⇧ + ← | Action: Move start of selection back > Move by word
⌥ + ⇧ + → | Action: Move end of selection forward > Move by word
your ⌘ C or ⌘ V will work to copy/paste these selections
Solution 2
in iterm it just moves the cursor without selecting. How do you get it to select >the text?
Yeah, iTerm has a special technique for text selection. Takes a little getting used to, but it's way faster than the ol' "shift+arrow" mac OS method.
If the text you want to select is anywhere in your current session's scrollback, just hit ⌘
+f
and then type the first few characters you want to select. iTerm will find the text and highlight it.
Then, hit tab
to extend the selection to the end of the next word, repeating tab
as many times as you need to fully select your required text.
When you're satisfied with the selection, go ahead and punch in your (⌘
+c
) + (⌘
+V
) or what have you.
Bonus: You can also use shift
+tab
to extend your selection backwards to the start of the previous word.
Solution 3
To extend @merlin answer here are some more iTerm2 key bindings for navigation/deletion
⌘ Del | send hex 0x15 | delete line
⌥ Del | send hex 0x1B 0x08 | delete word
⌘ ← | send hex 0x01 | move a cursor to the beginning of a line
⌘ → | send hex 0x05 | move a cursor to the end of a line
⌥ ← | send esc seq Esc+b | move a cursor to the left by word
⌥ → | send esc seq Esc+f | move a cursor to the right by word
⇧ ⌥ ← | move start of sel back by word | select to the left by word
⇧ ⌥ → | move end of sel forward by word | select to the right by word
truth1ness
Updated on June 13, 2022Comments
-
truth1ness almost 2 years
On most mac applications Shift+Arrow selects text but in iterm it just moves the cursor without selecting. How do you get it to select the text?
Would also be curious if there's a way to do this in terminal.app, too.
-
Lior Yehezkely over 2 yearsShirt+Option+RightArrow/LeftArrow result in ;10C & ;10D being typed. How to make them performed as mentioned in this answer? I assume it's some setting in the preferences that I am unaware of. I will note that in my Profile "keys" settings I use "Natural Text Editing"
-
danylokos over 2 yearsHere is mine .itermkeymap, but as far as I remember, I've not changed anything in settings except the key bindings.