How to fold multiple single line comments in visual studio code - visual-studio-code

As per the solution from previous posts, I tried to fold all blocked comments from the command palette but nothing happens. I have tried a lot of extensions/plugins but still, I can't fold them. Any solution to this? I have to close everything manually. However, in the IDE I can fold multiple single-line comments by hitting the down arrow on the left. Is there any shortcut or particular plugin/ extension for this ?
Am I commenting in the wrong way?

You have used // which is a single line comment
Use /*...your code ...*/ for block comments
Shortcut for block comment is Ctrl+Shift+A in VS Code

Yes. Press Ctrl+K then press Ctrl+/.

Related

VS Code with Vim extension: ctrl+d does not go half a page down but instead goes to "Select Environment"

I checked VS Code shortcut bindings, but do not see why "ctrl+d" will open "Select Environment" instead. That does not even appear in the shortcut bindings. Any idea how I can make it go half a page down instead?
I'm assuming you're using the Vim extension and expect it to page down.
If you select one of the environments (like Node.js for me), it should work after.
In case someone ever met this problem again, I solved this problem by entering command mode (press :) and escape.
I still am not sure what happened.

How do I select all text in vistual studio code?

In visual studio code (1.29.1) ctrl+a doesn't do anything for me. I checked keyboard shortcuts and it's mapped to a few select all actions (editor.action.selectAll, etc.) but when I'm in a file and press it nothing happens. How do I select all text in the current file in visual studio code?
Thanks for the comments, it make me realize it must be an environmental issue. Turns out if you have any mapping starting with a key combination that will lock that mapping to the key combo and you can't use it for anything else.
To make save all ctrl+shift+s I had to re-map save as and I mapped it to ctrl+a+s, so everytime I hit ctrl+a it just waiting for second key. In the status bar at the bottom of my editor it said something like "Ctrl+a detected, waiting for second keystroke", which means Ctrl+a won't work on its own. I re-mapped Save As to some unused key combo and it fixed select all.
This question was luckily answered on another thread
I'll post the OG answer here, nonetheless.
Most new comers to VS-Code could resolve this issue with the 2nd method provided by the OG answer:
Goto File > Preferences > Keyboard Shortcuts
in the search bar type this Select All
There's should a couple of results, you'll obviously want the "Select All" result
right click on his line and click on Change When Expression
a textbox would be highlight for you to fill in text. type editorFocus
press enter and done!
The OG answer provides image if you need to confirm that you're doing it right.
side-note: This issue bugged for more than 3 years and is the main reason my I used VS-Community over VS-Code.
So it's nice to finally be able to work normally in this very robust customizable IDE text-editor.

Does VS Code has any shortcut like ctrl+q in eclipse?

Does VS Code (I currently use v1.8.1) has any shortcut like ctrl+q in eclipse?
It returns your cursor to the place where you stopped writing code(very useful for fast code browsing)
and it is different to alt+left which navigate backward
EDIT: I have found that this extension should do that you're asking. I suggest trying it out.
Original:
Out of the box in VS Code, this command does not exist. The list of default shortcuts can be found here, or you can open the keybindings settings in VS Code (ctrl+k, ctrl+s on Windows) and see which commands are available.
If you'd like to suggest this as a feature, you can open a new issue on GitHub or consider creating an extension.
If I understand correctly, you want a command that will move the cursor to where the last edit in a document was made.
This should be possible using an extension that listens to document change events and records the position of the cursor. Then, when the command is issued, it sets the editors cursor to that saved position.
You can also try "Eclipse Keymap" from Alphabot Security, has a lot of eclipse bindings.
I don't believe there is a built-in way to do this, but you could work around it by using an extension such as https://marketplace.visualstudio.com/items?itemName=alefragnani.Bookmarks .

Undo editor.action.addSelectionToNextFindMatch?

What's the opposite of editor.action.addSelectionToNextFindMatch in Visual Studio Code? i.e. undo the last selection it added.
In PhpStorm this is Alt+J and Alt+Shift+J is undo.
In Sublime, this is Ctrl+D, but I'm not sure if Sublime has the opposite.
Sometimes I get overzealous with my keybashing and have to go back one.
Seems like cursorUndo (cmd+u) would do the trick, although it's not a dedicated command for this purpose.
https://github.com/Microsoft/vscode/issues/6872
I might just I did open a PR for it.
I know this has already been answered but I wanted to mention that I published an extension to solve this exact issue and add a few other features like being able to tab through your multiple cursors, remove all multi-cursor selections except the very last one, etc.
Check it out here https://marketplace.visualstudio.com/items?itemName=danseethaler.tab-through-selections
Esc once will un-toggle multiple-cursors.
Pressing Esc again toggles the currently highlighted selection.
As others have said, Cmd + U will undo the last highlighted item if you accidentally select one too many.

hiding comments in matlab's editor

Is there a simple way to hide the comments while you're writing your code in matlab's editor?
I have too many comments and they really get on my nerves sometimes.
I did a little search and was surprised to find nothing on this simple issue!
Thank you in advance
One solution would be to use block comments
%{
Hello World
%}
and code folding (Preferences > Editor > Code folding)
And with right-click on the editor window you can "Fold all" then.
If you don't want to get your functions and loops folded as well, uncheck that in the preferences.
I'm afraid there is no way in the Matlab Editor to hide all commented lines in general. You will need alternative editors like Notepad++ to do that.
thewaywewalk's answer is probably what you were looking for, but for the sake of completeness: Even without block comments you can always fold the first comment in a function definition.
Before:
After: