How to comment and uncomment multiple erb lines using Visual Studio Code? - visual-studio-code

It seems there is no way to comment and uncomment erb files using Visual Studio Code. I wonder if it is any extension out there. Actually I tried almost every code I found on the internet.
I tried the extension Ruby on Rails support for Visual Studio Code, but couldn't figure out how to uncomment multiple lines. Any hint appreciated.

try ctrl + / after select to comment/uncomment multiple line of code.

Related

Visual Studio Code Copy working but not properly

Hi my visual studio code does this weird single line paste whenever I copy a code from a pdf or any other sources.
this picture below is what I copied from
this is what happens when I paste my code
Not really sure what made it this way but I have tried reinstalling, deleting the cache, all the files related to visual studio code but it doesn't work.
The reason why I am asking this because it used to work and my friends that use vscode doesn't have this problem.
Your help is very much appreciated.

Possible to paste into jsdoc comment in Visual Studio Code and have asterisks added to each line?

Is there a way of pasting multiple lines of text into a jsdoc comment in Visual Studio Code and have asterisks added to each line? (Or more generally, of pasting into some sort of comment environment, whether line or block, and "doing the right thing"?)
Any relevant extensions?
I suspect that there is not built-in support, given that I can't see any relevant commands and [this issue] was closed for lack of interest and has not been linked to.
Try this extension jsdoc-comment-toggler
https://marketplace.visualstudio.com/items?itemName=zachhardesty.jsdoc-comment-toggler&ssr=false#review-details

How to show line numbers of a python notebook in Visual Studio Code

I think it should be quite straightforward, however, I cannot seem to find this option in visual studio code.
Could you tell me if it is possible and how to enable line numbers in visual studio code when coding in a python notebook?
FYI: it is possible to use visual studio code with a python notebook (you can check more info here)
You have to press L after clicking on the left side of the code block.
as mention in the link provided you just need to press the L key
https://code.visualstudio.com/docs/python/jupyter-support#_enabledisable-line-numbers

How to copy formatted code to clipboard in VS Code

In Visual Studio Code, is it possible to copy selected code to the clipboard with the syntax highlighting? I want to be able to paste into a Word doc or e-mail.
Regular Visual Studio does this by default (it puts both text and RTF formats on the clipboard).
I see that I can "Toggle Developer Tools" and locate the div (with class="view-lines") that has the code, so maybe there is a way to use that chunk of html, but I don't see an easy way to just copy the formatted code and paste into Word or an e-mail.
According to the 1.10 changelog : https://code.visualstudio.com/updates/v1_10#_copy-with-syntax-highlighting
It is now possible with that command : editor.action.clipboardCopyWithSyntaxHighlightingAction
Type/paste it in command box (ctrl+shift+p or F1)
Use the command "Copy With Syntax Highlighting".
Highlight the code
Ctrl + Shift + p to open the Command Palette
Type / Select Copy With Syntax Highlighting
It is available since VS Code v1.43 (Feb 2020), as #robert4 mentioned in comment.
Ran into this question as I was trying to copy and paste with syntax highlighting from Visual Studio (not Code). As far as I see, it is not possible OOTB.
I am using Visual Studio Enterprise 2019 (v16.7.4), trying to copy C# code (tried CSHTML also).
BUT, I found this article, which seemed to indicate that Visual Studio Code OOTB would Ctrl+C Ctrl+V right into an Outlook email or Word document without a plugin or fancy keyboard shortcut, and I was successful!
I am using Visual Studio Code v1.49.2, and copying C# code. Copying CSHTML also worked.
I took the suggestion above, went to the command pallet, clicked on the clog to the right, and used ctl + c for the key bindings. Now, when I copy from VSCode to OneNote, I get the source formatting. It works!

How do I auto-indent Python code in Visual Studio Code?

I'm using Visual Studio Code (not Visual Studio) on Linux and I can't seem to find out how to turn on auto-indentation for Python. I've looked all over preferences, spent some time on Google, and can't find anything.
Does anyone know how to do this?
In VS Code you can set the indentation in several places :
General/Workspace settings (bottom bar),
User settings,
language formatter settings.
When using Python, no matter what settings you set, all of them are overridden by the autopep8Args value of the autopep8 language formatter setting, which has an indent size of 4.
By default, autopep8 is used as VS Code Python formatter, but there are others, like yapf.
To update the indent size of this formatter, search in your user settings the "python.formatting.autopep8Args" and set it to : ["--indent-size=2"],
"python.formatting.autopep8Args": ["--indent-size=2"],
Visual Studio Code doesn't have much support for Python (yet), aside from syntax-highlighting, and per-file intellisense (meaning it'll provide suggestions for symbols that have been found within the current file).
I'm willing to bet that the Visual Studio Code team will, eventually, increase their support for Python within Visual Studio Code, and with this, they'll likely add support for auto-indentation.
In the meantime, it might be worth trying this Visual Studio Code extension, which aims to add better support for Python, into Visual Studio Code.
The extension does add auto-indentation for Python, to Visual Studio Code, along with many other features.
Happy scripting!
I auto-format python with autopep8, vscode can use it. It can be easily configured for tab-size and other stuff creating the config file: $HOME/.config/pep8
Here an example of that file:
[pep8]
indent-size = 2
max-line-length = 100