'vscode - swapping selected texts in vscode

I recently started using VSCode and I am really loving it. I Googled my question and dint find any answers related to VSCode.

Consider I am having the following code:

if (a === 'some condition') 
  return true
else
  return false

If I want swap or switch the return, i.e., I select true and false and is there any keyboard shortcuts or key binding to swap my selections.

Any help would be greatly appreciated.



Solution 1:[1]

Not that I know of. I also came across the same issue some time back.

You can use this Transpose plugin for VSCode

Hope this helps :)

PS - This is the issue thread from which I got to know about this plugin:

https://github.com/Microsoft/vscode/issues/12435

Solution 2:[2]

Use Any Swap (the most installed) plugin for swapping text in Visual Studio code

Solution 3:[3]

The Swap extension should work as you intended.


Keyboard Shortcut:

  • Windows: CTRL+ALT+8
  • Mac: CMD+OPTION+8

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sahan Serasinghe
Solution 2
Solution 3