QUESTION:
I have turned on wordWrap in VSCode, so that lines are wrapped if I resize the window.
If I want to comment out some code or text, I usually just move the cursor to the beginning of the first line of the block of code, use ctrl+shift+down to add cursors, and type the // or # etc..
The problem with wordWrap is that I do not only get cursors in the beginning of each actual line, but in the beginning of every line as it is displayed at the moment in the editor.
Assume the document:
1 This is the first line.
2 Second line.
which might be wrapped as follows:
1 This is the first
line.
2 Second line.
So if I use the method above and add % I would get:
1 %This is the first
%line.
2 %Second line.
But what I want is the following:
1 %This is the first
line.
2 %Second line.
Otherwise, I have a % in the middle of the line, just because I resize the editor window...
At the moment, I actually turn off wordWrap to achieve this, but I hope there is a better way?
PLEASE NOTE:
For adding comments, it is actually way simpler to use ctrl + / or shift + alt + a. But maybe the question is still interesting for other cases.
Right-click on each command that add a cursor and has a keyboard shortcut associated and select "Remove Keybinding". Also search for "Multi-Cursor". It could return the command "Toggle Multi-Cursor Modifier" that is associated to a combination of modifier keys (one or more of Ctrl , Alt , Shift ).
Follow the next steps:
Alt
+Shift
+i
to put a cursor on every selected lineCmd/Ctrl
+←
to move all cursors to the beginning of the [wrapped] linesCmd/Ctrl
+←
(again) to move all cursors to the actual beginning of the [wrapped] linesEnjoy! 🙂
This appears to be a known issue. The CursorColumnSelectOnTrueLines extension by Martin Zimmermann provides commands that show the desired behavior, by default mapped to Ctrl+Alt+Shift+Up/Down.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With