microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.19k stars 29.29k forks source link

Multiple Cursors - Preserve Case #106502

Open brianblakely opened 4 years ago

brianblakely commented 4 years ago

Use Case Take the following: const [value, setValue] = useState();

I want to change it to: const [array, setArray] = useState();

Feature Ask It would be great to:

  1. Select value.
  2. Press Ctrl+D.
  3. Type array.
  4. See that both symbols have changed, while preserving their proper casing.

Right now, I need to conduct two edit operations to do this. Alternatively, I can use a single Find & Replace operation, but that would be disproportionately time-consuming for this task, as well as less precise.

andig commented 4 years ago

Great requirement! I'm seeing this all the time when renaming across variables, types and functions.

I'd also- on a similar note- be able to keep the local casing during case-insensitive search/replace. I realise this is already possible. I'm having trouble keeping up ;)

emanuel-lundman commented 3 years ago

This should include cmd + shift + L, as well 🙂

hediet commented 3 years ago

I think it makes sense to have a button here (disabled by default): image

The button should look the same as the button in the search widget: image

The state of this button would apply whenever there is one or many selections and the user enters a character. If this feature is enabled and the selection starts with a captial letter, the new letter that is going to replace the selected text will also be capitalized.

andig commented 3 years ago

I think there are two sub features hidden in this issue:

It seems only the latter is scope of this issue while the former might actually be simpler to implement.

hediet commented 3 years ago

(currently case-insensitive)

It is case-sensitive when you also selected the first selection with Cmd+D. If you manually selected the first selection, it is case-insensitive (if you did not enable case-sensitivity in your last Cmd+f search).

andig commented 3 years ago

It is case-sensitive when you also selected the first selection with Cmd+D.

I don't follow. How can I select the first selection with Cmd-D? Imho Cmd-D expands the current selection with an additional cursor? Would be great if you could explain.

hediet commented 3 years ago

if you begin with a collapsed selection and press ctrl+d then the selection expands to the current word and for as long as you continue pressing ctrl+d, whole word and match case will be on

recording

if you begin with a non-collapsed selection and press ctrl+d, then the modifiers are taken from the last state of the find widget

recording

(from @alexdima) Collapsed selection means a selection of length 0.

berenar commented 1 year ago

Until this is not implemented, Multiple cursor case preserve extension does the trick 👍