-
Notifications
You must be signed in to change notification settings - Fork 0
Fix dsB keybinding for ** delimiter with workaround #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
6
commits into
main
Choose a base branch
from
copilot/fix-neovim-dsb-key-issue
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, delete_mostly_inner_surround and replace_mostly_inner_surround used 'va' + obj_key which relied on text objects like 'vaB'. For multi-character delimiters like '**', this only selected content with single '*' on each side (*foo*), not the full delimiter (**foo**). Now using 'viw' to select inner word first, then applying the operator with the key. This allows vim-operator-surround to properly find and operate on multi-character delimiters like '**'. Fixes the issue where dsB on **foo** resulted in *foo* instead of foo. Co-authored-by: aiya000 <4897842+aiya000@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix dsB key malfunction in Neovim normal mode
Fix dsB keybinding to properly delete multi-character delimiters
Dec 17, 2025
Owner
|
@copilot |
Owner
|
@copilot |
The previous fix broke the functionality entirely. The correct pattern for vim-operator-surround is to use the operator as a PREFIX (standard vim operator pattern), not as a suffix. Changed from: - `viw<Plug>(operator-surround-delete)B` (broken - delimiter ignored) To: - `<Plug>(operator-surround-delete)aB` (correct - operator first, then motion) The pattern is: operator + motion-specifier Where motion is `a` (around) + delimiter key (e.g., `B` for `**`) This properly uses vim-operator-surround's internal delimiter detection for multi-character delimiters like `**`. Co-authored-by: aiya000 <4897842+aiya000@users.noreply.github.com>
Contributor
Author
Owner
|
@copilot |
Changed pattern from: - `<Plug>(operator-surround-delete)aB` (operator + motion prefix) To: - `<Plug>(operator-surround-delete)iwB` (operator + motion + delimiter key) This pattern matches how replace works: operator + motion + key(s). The delimiter key comes after the motion, allowing the operator to know which specific delimiter to target from its internal configuration. Co-authored-by: aiya000 <4897842+aiya000@users.noreply.github.com>
Found that the B key for ** delimiter has never worked properly with vim-operator-surround. The old Vimscript implementation had a workaround that manually handles the B case. Implemented the same workaround: 1. Delete content between single * (leaves ** on each side) 2. Use substitution to replace **** with deleted content 3. Result: **foo** becomes foo This matches the workaround in .vim/autoload/vimrc.vim. Also reverted replace function to use original 'va' pattern which works for most delimiters (B doesn't need special handling for replace). Co-authored-by: aiya000 <4897842+aiya000@users.noreply.github.com>
Contributor
Author
Fixed three issues found in code review:
1. Use 'va' instead of 'iw' for non-B delimiters (matches original)
2. Use {ઠ"} instead of \=ઠ" in substitution (matches Vimscript)
3. Keep repeat command consistent with actual command
Now the Lua implementation exactly matches the proven Vimscript
implementation in .vim/autoload/vimrc.vim
Co-authored-by: aiya000 <4897842+aiya000@users.noreply.github.com>
Copilot
AI
changed the title
Fix dsB keybinding to properly delete multi-character delimiters
Fix dsB keybinding for ** delimiter with workaround
Dec 24, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
修正内容
問題
**foo**でdsBを押下してもfooにならず、*foo*になってしまう問題。根本原因
vim-operator-surroundの
Bキー(**区切り文字)は正しく動作しない既知の問題であることが判明しました。古いVimscript実装(.vim/autoload/vimrc.vim)でも同じ問題があり、ワークアラウンドが実装されていました。コメントより:
実装した解決策
Vimscript実装と同じワークアラウンドをLuaで実装:
ワークアラウンドの動作
**foo**でカーソルがfoo上にある場合:d<Plug>(textobj-between-i)*で単一*間のコンテンツを削除(**が両側に残る)s/\*\*\*\*/{@"}/で残った****を削除したコンテンツで置換**foo**→foo変更ファイル
.config/nvim/lua/nvim.luadelete_mostly_inner_surround():Bキーの特別処理を追加、他は元の'va'パターンを使用replace_mostly_inner_surround(): 元の'va'パターンに戻した期待される動作
**foo**でdsB→foo(ワークアラウンド使用)(foo)でds(→foo(元のパターン)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.