Skip to content

feat: add support for 'tildeop' option (~ as operator)#9993

Merged
J-Fields merged 13 commits into
VSCodeVim:masterfrom
benjaAguilar:feat-tildeop-support
Jun 5, 2026
Merged

feat: add support for 'tildeop' option (~ as operator)#9993
J-Fields merged 13 commits into
VSCodeVim:masterfrom
benjaAguilar:feat-tildeop-support

Conversation

@benjaAguilar

Copy link
Copy Markdown
Contributor

add support for the tildeop option, allowing ~ to behave as an operator when enabled, matching Vim behavior.

  • When tildeop = false (default):

    • ~ toggles the case of a single character (unchanged behavior)
  • When tildeop = true:

    • ~ acts as an operator and requires a motion (e.g. ~w, ~$)
    • ~~ toggles the entire line
    • g~ continues to work as before
  • In Visual and Visual Line modes:

    • ~ always toggles the selected text (independent of tildeop)

Implementation details

  • Added vim.tildeop configuration option
  • Updated action resolution to conditionally treat ~ as:
    • command
    • operator
    • motion (when used after an operator)
  • Ensured compatibility with existing operator flow (g~)
  • Preserved undo/redo behavior

Tests

Added tests covering:

  • Default behavior (tildeop = false)
  • Operator behavior (~w, ~$, 2~w)
  • Edge cases (~~, g~~)
  • Visual and Visual Line modes
  • Dynamic toggling via :set tildeop / :set notildeop

This implementation Closes #3094

Comment thread src/actions/commands/actions.ts Outdated
Comment thread src/actions/operator.ts Outdated
@benjaAguilar benjaAguilar force-pushed the feat-tildeop-support branch from 0170707 to 2962c9a Compare May 28, 2026 17:33
@benjaAguilar

Copy link
Copy Markdown
Contributor Author

Applied the requested changes and re-ran the tests successfully. Thanks for the review!

Comment thread src/actions/commands/actions.ts Outdated
Comment thread src/actions/operator.ts Outdated
Comment thread src/actions/operator.ts Outdated
Comment thread package.json
Comment thread src/configuration/configuration.ts
benjaAguilar and others added 8 commits June 1, 2026 09:43
… check

createsUndoPoint is unnecesary, its true in base class

TildeMotion is unnecesary:
its only purpose is to handle {operator}~
the ~~ case and is the only one that makes sense but the ~~ path already
works completely independently through a different mechanism

configuration.tildeop:
fixes g~~ in tildeop=false

@J-Fields J-Fields left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@J-Fields J-Fields merged commit ffdfb44 into VSCodeVim:master Jun 5, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support tildeop

2 participants