Back to Blog
Iterm delete line7/6/2023 Now you can kill word-by-word (from right to left aka backwards) by hitting Option-Backspace. Action: “send hex code”, and enter “17” (without the quotes).Add a new mapping (“ ” sign) and configure its parameters: Go to Bookmarks > Manage Profiles… and open Keyboard Profiles > Global (just like in the previous sections). If you want to enable “backward-kill-word”, add another shortcut with the following configuration. Now you can use Option← and Option→ for word movement in iTerm! 4. Now, whenever you're typing a command in iTerm2, it's really easy to jump back to the start of the word (or even multiple words) to insert more text or delete part of the command no more need for repeatedly pressing the key to navigate back character by character. You can find their explanation among others in the man page of lesskey(1). The shell escape sequences ESC-b ( \eb, word-left) and ESC-f ( \ef, word-right), respectively, will do the trick. We need two shortcuts in total, one for word movement to the left with Option← and one for word movement to the right with Option→. Ok ok admittedly, you can already see in this screenshot that the shortcuts we are about to add do already exist – I was just too lazy to remove them before taking the picture. Click the button as shown in the screenshot below to add a new shortcut. Now, we will add two new shortcuts to the global keyboard file. Manage Profilesįirst, open the Manage Profiles menu in iTerm. Add the end, you can use Option← and Option→ for word movement to the left and right, respectively (if you prefer the Linux setup, you just use the Ctrl modifier instead of Option in the following steps). It’s quite easy actually and involves just a few steps. I’m not that familiar with shell escape sequences, so I was quite happy when I found out how to use them for adding word movement support to iTerm. Only the part killed by the second of those keystrokes will be saved in the kill buffer, but you can still do undo twice to recover them both.One of the things that has always bothered me about iTerm on Mac OS X is the lack of default keyboard shortcuts for moving from word to word like Ctrl← (cursor-left) and Ctrl→ (cursor-right) on standard Linux terminals. So instead of doing the binding described above, you can kill a whole line by pressing Ctrl- u Ctrl- k. Or you can paste back in (yank) what you killed by pressing Ctrl- y which can be repeated if you want multiple copies of that text.īy the way, if you want to kill text from the cursor to the end of the line, you can press Ctrl- k. To undo a Ctrl- u or Shift Alt- U (or any operation that can be undone), press Ctrl- Shift- _ (underscore) or Ctrl- x Ctrl- u (two keystrokes). Or make it persistent by putting this line in your ~/.inputrc file: "\eU":kill-whole-line You can try it out at the command line by creating the binding this way: bind '"\eU":kill-whole-line' Since we don't really need two keys to do that, let's use that one. That keystroke may be bound to do-lowercase-version which means it does whatever the unshifted version does (in this case upcase-word). I like Shift Alt- U since it's a related function. You can bind that to any available keystroke. There is a readline function that is probably not bound to a keystroke called kill-whole-line that will kill the whole line as opposed to only killing the part before the cursor ( unix-line-discard which is somewhat of a misnomer and is bound to Ctrl- u).
0 Comments
Read More
Leave a Reply. |