iTerm2 jump forward slashes

Viewed 177

What binding do I need to setup so I can jump to each forward slash in a path in iTerm2? I'm using a mac with BigSur.

Currently, I have my binding set up so it will skip by word. In the example below, if the cursor is at the end of the path (after the 'h'), and I hit option + left arrow, it will jump to colon after 's3'. I want it to jump to the '/' after 'file' and before 'path'.

s3://my-bucket/my/file/path
1 Answers

tl;dr: add two lines to your ~/.zshrc file:

autoload -U select-word-style
select-word-style bash

It looks like this is a matter of Mac switching to zsh from bash. I had this same problem -- slashes were treated as word breaks on my old MBP, but not on a newer one, and altering key mappings to various Escape sequences or Hex codes didn't seem to change anything.

Credit goes to the first two commenters on this answer. The answer itself just provides the hex codes for deleting word-wise, but using this zsh setting instantly fixed the forward/backward cursor movement for me, including slashes as word breaks (as they should be!).

Related