Zsh設定 - VSCodeの行ナビゲーション[閉じる]

Zsh設定 - VSCodeの行ナビゲーション[閉じる]

私は実際にこのような質問をしたことがあります。そしてスタックオーバーフロー。私はVSCodeを使用しており、良い動作をしています。Alt行末で+を実行すると、次の場所で停止します。

foo/bar/test_wait_what
    ^   ^    ^    ^     

Delete+をすると、、、などがAlt削除されます。what_wait

私はほぼ同じことをしたいと思いますzsh(すでに使用している「oh-my-zsh」なしでzimfw)。基本的には_単語区切り文字と見なさないようで、については/同時に削除します。

似たような質問をいくつか発見し、使用を提案しましたが、削除するselect-word-style bashと、bashは私が望む方法で動作しません。

zshまた、私が直接答えを見つけることができる方法に関する提案がある場合は、躊躇しないでください。明確な情報や例などを見つけるのは難しいです。

ベストアンサー1

(または単語の一部と見なされたくない他の文字)を_削除できます。/$WORDCHARS性格)バインドする単語または単語ではなく文字シーケンスを削除するウィジェットを定義します。Alt+Del

delete-word-or-non-word() {
  emulate -L zsh       # restore default zsh options locally to the function
  set -o extendedglob  # extended glob needed for the ## operator (locally)

  # ${var##pattern} ksh operator to remove the longest string that matches
  # the pattern off the start of $var. Here applied to $RBUFFER which in a
  # zle widget is the part of the line editor buffer to the right of the
  # cursor. [[:WORD:]] matches a *word* character (alnums + $WORDCHARS),
  # ## is *one or more* (like ERE's + or ksh's +(...))
  RBUFFER=${RBUFFER##([[:WORD:]]##|[^[:WORD:]]##)}
}

zle -N delete-word-or-non-word # define a new zle widget using that function

# bind that new widget
bindkey '\ed' delete-word-or-non-word      # Alt+D
bindkey '^[[3;3~' delete-word-or-non-word  # Alt+Del on xterm at least

WORDCHARS=${WORDCHARS//[\/_]}  # remove _ and / from WORDCHARS
                               # using the ${var//pattern/replacement} ksh
                               # operator

WORDCHARS=                     # or make it empty so that the only *word*
                               # characters are alphanumerics

(これは必要ありませんselect-word-style

おすすめ記事