@@ -80,6 +80,67 @@ There are many `*-kill-*` widgets available that will let you kill words, lines,
8080
8181If you don't want to feel like a murderer you can also try the ` *-yank-* ` and ` *-push-* ` widgets too.
8282
83+ ### Advance Word Movements and Modifications
84+ When jumping between words (for example ` [^f ` and ` [^b ` for forward and backwards in emacs mode). The shell uses a few different
85+ things to define what a "word" is. By default you can ` echo $WORDCHARS ` to see all the special characters the shell will include
86+ as a single word. For example the default is:
87+ ```
88+ $ echo $WORDCHARS
89+ *?_-.[]~=/&;!#$%^(){}<>
90+ ```
91+ This means that any alphanumeric character plus any of the above will be combined to be a single word. Notice how ` / ` is
92+ included in the above. This means ` foo/bar-bazz ` will be one word to be acted upon.
93+
94+ If you are coming from bash and want your jump/delete word functions to stop at ` / ` and ` - ` you can add this in
95+ your .zshrc:
96+ ```
97+ autoload -U select-word-style
98+ select-word-style bash
99+ ```
100+ Without it ` [^D ` will delete a full directory path. For example:
101+ ```
102+ ## Without
103+ $ cd /project/example/delete
104+ ## Press [^D from front beginning of line
105+ $ /project/example/delete
106+ ## Press [^D again
107+ $
108+
109+ ## With select-word-style bash
110+ $ cd /project/example/delete
111+ ## Press [^D from front beginning of line
112+ $ /project/example/delete
113+ ## Press [^D again
114+ $ /example/delete
115+ ```
116+ You can learn about the available word styles and their behavior [ here] ( https://linux.die.net/man/1/zshcontrib ) (search for ` select-word-syle ` ).
117+ But here is a quick explanation:
118+ ```
119+ $ select-word-style
120+ Usage: select-word-style word-style
121+ where word-style is one of the characters in parentheses:
122+ (b)ash: Word characters are alphanumerics only
123+ (n)ormal: Word characters are alphanumerics plus $WORDCHARS
124+ (s)hell: Words are command arguments using shell syntax
125+ (w)hitespace: Words are whitespace-delimited
126+ (d)efault: Use default, no special handling (usually same as `n')
127+ (q)uit: Quit without setting a new style
128+ ```
129+ One important thing to note is that any ` select-word-style ` that is not ` normal ` will may not respect ` $WORDCHARS ` .
130+ When in ` normal ` select-word-style all alphanumeric characters plus anything in ` $WORDCHARS ` is used by zsh to determine
131+ when to stop its action. If you want even more control feel free to set the var directly. This can then be used to make your
132+ backwards jump different than your forwards jump.
133+ For example if I want my backward delete to delete a whole directory path I can set this:
134+ ```
135+ ## with word-style set to `normal` but $WORDCHARS=''
136+ default-backward-delete-word () {
137+ local WORDCHARS="*?_[]~=/&;!#$%^(){}<>"
138+ zle backward-delete-word
139+ }
140+ zle -N default-backward-delete-word
141+ bindkey '^W' default-backward-delete-word
142+ ```
143+
83144### Yank current command and paste
84145
85146For example, let's say you have a long command line typed up but you forgot you needed to run a command first or look up some information.
0 commit comments