Autoformat in VS Code on semicolon, enter, etc - visual-studio-code

Is there a way to make VS Code work with autoformat like other VS versions ?
Mostly I want it to autoformat the line/block when I close it( so with ; } ).
Also I would like to autotab in advance when I make empty lines or similar empty blocks while the default behaviour is to just stay at starting tab.
I program mainly in C#.

Related

VSCode Intellisense Completion - Assembly Language

I'm using VSCode to write in 6510 assembly language for C64, and I'm running into a problem with Intellisense. I'm using the Kick Assembler C64 for VS Code. So I expected the 6510 assembly mnemonics to be recognized, which it seems like they are. The problem I'm running into is after typing the three letter opcode mnemonic and hitting tab to select it, the cursor moves one space past it (which is fine), but then Intellisense immediately starts making suggestions, so that I cannot hit the tab key again to create the space I'd like between the opcode mnemonic and the operand.
Is there a way to make Intellisense hold off on making suggestions until after I've typed that first character of the operand? I'd rather not turn it off completely and slow myself way down.
Thanks,

Visual Studio Code bracket auto completion

This has been annoying me for a while. VSCode doesn't let me type a closing bracked or parenthesis or the like ( ")", "]", "}") when there is already a closing symbol of the same type.
In this WEBM you see me try to set another set of brackets and VSCode skips the closing bracket that I typed. This is extremely annoying.
WEBM
How do I disable this behaviour in VSCode? (Or correct it, so VSCode closes the inner bracket for me.)
Edit: I know I can disable auto closing brackets in VSCode with "editor.autoClosingBrackets": false. But I don't want to disable it altogether. I just want to disable the overtyping.
TL;DR: As of June 2019, it's not possible to disable only the overtyping part of the autocloseBrackets function. You can only disable auto
bracket closing altogether.
Some people suggest using the TabOut Extension for Visual Studio Code to tab out of quotes, brackets, etc.
Ok, so what I found out over at the VSC Github is this:
[...] This can be turned off via editor.autoClosingBrackets. The feature
consists of multiple parts:
one is that when ( is typed, the result is (|).
the other part that is hit here, is that when ) is typed and ) follows the cursor, ) will be overtyped.
The feature is implemented language agnostic and looks only locally at
the next character. It does not count brackets to determine if the
code is "bracket unbalanced".
(Source: https://github.com/Microsoft/vscode/issues/35799)
At the moment, it's not possible to fix this, without losing the auto
bracket closing feature. The above thread has since been closed. New one is here: https://github.com/Microsoft/vscode/issues/37315 , but no patch has come out yet.
I face the same issue,
It's because of the GIT COPILOT once I uninstall and restart the VS CODE it's working properly now

find_under_expand in VS Code

I'm trying to move to VS Code, and really like many of the feature.
But I'm really missing one of the most powerful editing features of sublime text: find_under_expand
i.e. select word with cursor, the select all other concurrences of this word by hitting ctrl+d.
Is there a way to reproduce this behavior in VS Code.
Ctrl-Shift-L : keyboard shortcuts, search for select all.
Ctrl-D adds the next match to the selection one-by-one.

Is it possible to auto-indent only the current line on Visual Studio Code?

On Atom (and many other editors), there is the auto-indent command which allows us to auto-indent the line the cursor is on. Is there an equivalent in Visual Studio Code ?
I know there is the formatter action on Visual Studio Code but from what i have seen, it can be used only to :
format a selection (ctrl-K ctrl-F)
format the hole document (ctrl + shift + I)
I would like to be able to format the line the cursor is on without reformating the whole document and without having to make a selection.
Basically, i would like to configure the [TAB] key so that when i press [TAB], it auto-indents only the line the cursor is on :
if there is nothing written on the line, it just put the cursor at the right place so that when i start writting, the code is correctly indented.
if there is already something written on the line, it audo-indents the line
Is it possible ?
So I have skimmed through the source code and seems there is no setting currently available to make this happen. There is a lot of work happening in pipeline for indentation
https://github.com/Microsoft/vscode/issues/17868
VSCode use Monaco Editor under the hood
https://github.com/Microsoft/monaco-editor/issues/612
The current python configs are located in
https://github.com/Microsoft/vscode/tree/master/extensions/python
I tried, but understanding how all this integrates and works together just to fix one indent issue was just overwhelming. So I would just for the time being open a enhancement request with VScode and let the experts take a call and do the job
Allow me to humbly suggest that you are looking for the solution in the wrong place.
I would suggest the following setting:
"editor.formatOnType": true,
You have focused on "tab" doing the correct indentation. But with this setting you need not press the tab key at all. Just type the line with a normal return at the end. Visual Studio Code will then indent (and format) that line correctly.
If you install the extension emacs-tab, you can do this:
{
"key": "tab",
"command": "emacs-tab.reindentCurrentLine",
"when": "editorTextFocus"
}
Which, as far as I understand you, does exactly what you want (and doesn't format the line in other ways, such as breaking it if it is too long, and so on).
This extension worked for me, and allows typing Tab with the cursor mid-line to get proper indentation similar to what I was used to on Emacs.
Note that it basically does the same as the extension recommended in this answer but at the time of this writing that extension appears to be unmaintained and has some open issues.

Emacs - How to keep text formatted to other editors?

I'm a beginner with emacs. Altough I'm finding it amusing and challenging, I still don't know some basic things, like, when I open a text or a piece of script wrote in another editors, emacs don't show the text formatted properly (missing all tabs, all text left-aligned) and vice-versa.
Also, when I copy a link with emacs with M-w, my clipboard is still empty and I can't paste it in a browser. I already did my "homework". I've read the tutorial and I'm almost finishing the manual and didn't see anything to address that.
tnx in advance.
Some editors, like Intellij IDEA for example, will indent code based on how they understand it and not based on how it was actually indented, there's no Emacs mode that operates in the same way, not to my best knowledge. If you were using something like Eclipse or MS Visual Studio before - then you probably just have a different size of tab character (this is why some programmers insist on indenting code with spaces rather than tabs). But the width of the tab character is adjustable. In order to customize it you would:
add in your initialization file (usually .emacs file in your $HOME directory, you can create one, if it is not there yet):
;; makes tab character as wide as four space characters
(setq default-tab-width 4)
though some other major editing modes override this variable, you would need to tell what language you are dealing with to get better instructions.
Clipboard, see this answer: How to copy text from Emacs to another application on Linux if you are on Linux, then likely you need to set x-select-enable-clipboard to t.
Aligning text to the right (or left for LTR languages) is not possible in Emacs, as far as I understand. You could align block of text, if you split it into lines and align on the line ends, but that would mean aligning by adding spaces at the beginning - something you don't really want to do.
Tabs should work (you might need to fix the width). Use mouse to select to the clipboard, or use CtrlInsert to copy and ShiftDelete to cut.
Assuming emacs has picked the right mode for the file - it usually does - you can press C-x h to select all, then TAB to indent all selected lines. What other editors are you using, and what platform(s)?
As for the clipboard issue, some builds of emacs work correctly with the native clipboard, some don't. You might want to investigate CUA mode.