How do i prevent vscode from breaking my pasted code? - visual-studio-code

Im not using any plugins for breaking my code, i think it's an integrated function. This problem is now since a few weeks and it's driving me crazy pasting code and then putting every line back.
Here is a screenshot of my code (i just copied this line):
https://imgur.com/YOdfM2u
Here is a screenshot of my code (i pasted it):
https://imgur.com/1AfzNIH
Why is my vscode breaking the lines everytime?
Thanks in advance for your help, i really apreciate it

This is the default formatter wrapping text (or trying to) at the default of 80 columns.
If you want to override this, you can do so by adding this line to your settings.json file:
"html.format.wrapLineLength": 0
If you prefer to change your settings from the GUI instead of the json file, open the command palette and open the settings from there. Once in it, look for "HTML format wrap line length" in the search box and change the value to 0.
You find a shortcut to the settings here too:

Related

How can I put a HTML tag in one line in VS Code?

The VS Code in my Mac pc is automatically breaking the customer HTML tags in new lines. This is making the length of the whole code much bigger.
For example, I want below code in one line
<FormInput name="propertyTax" width="43%" height="7%" placeholder="3,200"></FormInput>
But the VS code is showing as below.
<FormInput
name="propertyTax"
width="43%"
height="7%"
placeholder="3,200">
</FormInput>
I tried change wordwrap from settings with no luck.
Please help me.
Just press F1, and type: join lines
You can try switching off any formatters that you have in VSCOde. Go to Code > Preferences > Settings and search for "Format" and try switching off "Format on Save" and any other format option that you have.
If you're using Prettier formatter. Go to Settings and search for this: prettier.printWidth and change from default 80 to 300.

How can I make Visual Studio Code suggest tab-completions for any previous line in the file?

I want visual studio code to suggest an autocompletion for an entire line if I start typing the first few characters of any line already in the file, regardless of the content of the existing line. So if this is the content of my file:
this is a line with whitespace
this,is,a,comma,separated,list
And I type this on a new line, I would get a pop-up like any other autocomplete suggestion and I could fill in either of the lines above. How can I do this (and if I can't, is there another editor that has this ability)?
The extension Line Completion does what you want.
You have to configure for which files (language identifiers) it should perform these suggestions. (To prevent to much calculation on large files where you don't use it. See the README page.

Prettier extention formatting is going weird

When I write a long paragraph it looks normal. But after saving (formatting) it looks weird.
FYI word-wrapping and format on save was on.
This is before formatting
This is after formatting
Please help.
VS code wraps long lines if they exceed a certain length if "format on save" is on. To disable it, set the maximum length to 0.
Press Ctrl+Shift+P to bring up the command palette and run the Preferences: Open JSON Settings command. Add the following line:
"html.format.wrapLineLength": 0
Okey, It's the window width. If I maximize vscode the promlem is gone.

Visual Studio Code / VS Code: Turn off Cursor line/Current line Highlight option

I'm not sure how I made this feature but I can't stop highlighting the cursor line. As you can see, I have a green underline at the position of the cursor line.
This feature is good if you do not use .ipynb/jupyter file but if you do you can see this:
I have looked all settings and also deleted .json setting file parameters to be sure not there but did not work.
Does anyone knows the exact parameter name that I can turn off this feature?
I have similar issue, but later I found that is the column select mode. You need to remove it from the setting.json
"editor.columnSelection": true

Eclipse: Automatic line wrapping to specified width

I'd like for my lines, especially within comments, to be automatically managed so they don't get too long.
I remember once I had a configuration for vim which automatically moved the word I was typing to the next line once I reached 72 characters. It wasn't smart enough to rearrange the paragraph if I edit it, but it was a start.
Is there something that can manage these for me? I have a tendency to write really long comments in my code, and it helps to make them look neat by having consistent width, but it's always a pain to do this because oftentimes editing a sentence requires editing the entire rest of the paragraph.
I have just recently discovered the Ctrl+Shift+F feature. It is amazing and superior to Ctrl+I which is what I was using up till now, but I noticed that it does not do anything to clean up my comments.
Update: The answers are correct when working with Java in Eclipse. It seems like I have to wait for the CDT to incorporate this feature.
In "Windows -> Preferences", go to "Java -> Code style -> Formatter" to customize the formatter (called when you click Ctrl+Shift+F). In the tab "comment", you can set the maximum line width for comments (it can be different then the line width for code).
Tip: in the preferences, "Java -> Editor -> Save actions", you can make Eclipse to automatically format your file when you save it, so your code is always correctly indented !
The automatic formatting of Eclipse great no question.
If your comments are reformatted depends on what comment type and how you already have inserted line breaks.
Writing for example one very long line comment starting with // will be broken down by the formatter into multiple lines.
However you later edit the formatted lines - e.g. delete parts of it the formatter will leave them as they are. Only over-long lines will be changed.
Just in difference to block comments like this: /* comment */
Those comments will always be re-formatted in case the line is too short or too long.
If you want to format your header comment, you have to check Enable header comment formatting - that was the trick for me.
Obviously, to use this, you must create new formatter profile.