How to make navigation / delete zsh with words like Vim

I am using zsh and I want text navigation / deletion to work exactly as it does in Vim to fit my muscle memory.

In Vim, given the text foo ./bar baz-bob , each fast forward starting from the first character looks like this:

 foo ./bar baz-bob ^ ^ ^ ^ ^^ 

By default zsh, it looks like this:

 foo ./bar baz-bob ^ ^ ^ ^ 

I managed to succeed using WORDCHARS=${WORDCHARS//[\/-]} . As I understand it, this works by removing the / and - characters from WORDCHARS . WORDCHARS is a string of characters that are also part of a word.

 foo ./bar baz-bob ^ ^ ^ ^ ^ ^ 

Note. I am aware of zsh vi mode, but I would prefer to set the default zsh mode this way.

+5
source share
2 answers

Have you checked this one ? You can re-export the WORDCHARS environment variable without a dash.

0
source

For the latest MacOS Sierra + iTerm2 + oh-my-zsh, if I constantly press CTRL W after entering cd /usr/local/share/gobject-introspection-1.0 , then the story will look like this:

 cd /usr/local/share/gobject-introspection-1.0 cd /usr/local/share/gobject-introspection-1. cd /usr/local/share/gobject-introspection- cd /usr/local/share/gobject- cd /usr/local/share/ cd /usr/local/ 

I do not have key binding files or other files. I don't like too many files. Here is my .zshrc necessary part:

 ... bindkey -e bindkey '^[[1;9C' forward-word bindkey '^[[1;9D' backward-word ... 

If the above doesn't work or you don't like it, you can try this on ~/.zshrc :

 WORDCHARS='*?_-.[]~=&;!#$%^(){}<>' 

or:

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

or ( I found the following value listed here ):

 tcsh-backward-delete-word () { local WORDCHARS="${WORDCHARS:s#/#}" zle backward-delete-word } bindkey '^W' tcsh-backward-delete-word 
0
source

Source: https://habr.com/ru/post/1260203/


All Articles