Select text in iTerm using keyboard

50

22

Is there a way to select text in iTerm OSX using keyboard?

Don Ch

Posted 2010-01-09T17:34:19.763

Reputation: 4 869

Answers

64

Yes! In iTerm2, do this:

From the relevant documentation

  1. Cmd-F
  2. Type some text that matches part of what you want to copy.
  3. When you have a partial match on what you want to copy, you can expand the selection.

Press tab to grow it one word to the right; press shift-tab to grow it one word to the left.

As soon as you press tab or shift-tab, it is copied to the clipboard. You can press option-Enter to immediately paste the selection and close the find bar at once.

You could also assign custom keys in Prefs -> Keys. (Source)

move selection forward by word

move selection backward by word

Similarly settings can also be used to move line selection.

Alternatively, the autocorrect feature reduces the need for copy-paste. Just type the start of some text that is either on the screen or you have copy-pasted recently and press cmd-;. A popup window appears and you can choose from there. Autocorrect works best for a single word, though.

(I updated this answer to reflect new features in iTerm 3.0. Thanks to @sfarzy for the suggested edits)

George

Posted 2010-01-09T17:34:19.763

Reputation: 1 496

2no fun workaround – Mirko – 2015-05-06T18:42:31.570

Aformentioned autocorrect feature FTW! much quicker than the find based approach which is why I came here to begin with. Surprised they don't advertise this more! – John Culviner – 2016-04-14T16:34:28.420

thanks. This is the only work-around I've found so far. However, I can't get it to go beyond a single line. Is that possible? – Rob Bednark – 2012-11-21T15:47:53.210

3If you have multiple matches, press cmd-G to go to the next match. Press shift-cmd-G to go the other way. – gitaarik – 2013-08-07T10:22:33.710

13

You can use "Edit->Copy Mode" by default Shift+Cmd+C, In there you can use VIM-like shortcuts:

/ will allow you to search, v to select, And while selecting you can use $ to move to the end of the line and finally the good ol' Cmd + C to copy.

Richard

Posted 2010-01-09T17:34:19.763

Reputation: 231

3Nice. Or simply y to copy (and return to normal mode). – friederbluemle – 2019-11-19T04:34:42.383

6

From the iTerm2 documentation:

Text Selection

There are two ways to select text to copy to the clipboard: you can use the mouse, or you can use the find feature's "mouseless copy" feature. Text selection by mouse is described later in General Usage section.

To select text without using the mouse, press cmd-f to open the find field. Enter the beginning of the text you wish to copy and the find feature will select it in your window. Then press tab and the end of the selection will advance by a word. To move the beginning of the selection to the left, press shift-tab. At most one line of text can be selected this way.

Carlos Baraza

Posted 2010-01-09T17:34:19.763

Reputation: 61

Re: At most one line of text can be selected this way. I was unfortunately able to select multiple lines. Would you know how to turn that "feature" off by any chance? – Gabriel – 2016-11-13T19:42:51.780

3while this works, it is a horrible and slow way to do such a simple thing – Yerken – 2016-12-28T15:55:49.170

This is close to what I want but it would be great to do this quickly with a one key shortcut like ctrl+p to go through the command history. – Chucky – 2019-07-19T14:32:37.990