Skip to content

feat(vi): add u, U visual mode commands#1087

Open
matystroia wants to merge 1 commit into
nushell:mainfrom
matystroia:vi-mode-uppercase
Open

feat(vi): add u, U visual mode commands#1087
matystroia wants to merge 1 commit into
nushell:mainfrom
matystroia:vi-mode-uppercase

Conversation

@matystroia
Copy link
Copy Markdown

This PR adds the following commands to visual mode:

  • u to convert selection to lowercase
  • U to convert selection to uppercase
  • ~ to switch case for each character in selection

These match default vim mappings and would be especially useful when working with environment variables.

Added:

  • Command::Lowercase
  • Command::Uppercase
  • EditCommand::LowercaseSelection
  • EditCommand::UppercaseSelection
  • EditCommand::SwitchcaseSelection

@matystroia matystroia force-pushed the vi-mode-uppercase branch from 18d755a to 006825a Compare May 28, 2026 09:16
@matystroia matystroia marked this pull request as ready for review May 28, 2026 09:17
@kronberger-droid
Copy link
Copy Markdown
Collaborator

Thanks for this.
Parser logic and mode guards look right and u/U/~ in visual mode go through cleanly, and u → Undo in normal mode is properly gated.

One pre-existing limitation this surfaces: vi/mod.rs:86-89 consults normal_keybindings in both Normal and Visual modes.
Users with bare u rebound to Undo will see undo fire in Visual instead of Lowercase.
The parser's mode gates are correct, but the keybinding lookup runs first.
I will have to make a follow-up PR for adding visual_keybindings to Vi so this doesn't entangle.

Also what through me off while testing is that single grapheme selections don't work, which is a repeating issue for Vi Mode.

But all of these are not your problems to worry about. Fine with landing this now and thinking about the other stuff in follow-ups.

@fdncred are you fine with this?

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 28, 2026

Seems reasonable. It's up to you @kronberger-droid

@matystroia
Copy link
Copy Markdown
Author

Also what through me off while testing is that single grapheme selections don't work, which is a repeating issue for Vi Mode.

I noticed this as well since vU is a common pattern for capitalization. Fortunately I think the fix for it is fairly simple! I've created a draft PR for it here: #1089

@kronberger-droid
Copy link
Copy Markdown
Collaborator

Could you still add a couple tests:

Otherwise good to land once tests are in.

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.

3 participants