Content of tags is not getting on the same line after certain point & it is getting added to the next line . How to get that content on the same line? - visual-studio-code

I am coding HTML & CSS in VS Code IDE. I have installed & enabled the prettier extension for better readability of the code & auto-indentation. but my content of tags is not going beyond that certain point on the screen & it is getting added to the next line whenever I save my code by Ctrl +S (example: see the last paragraph tag). How to get that content on the same line?

You shouldn't use Prettier if you don't need this behavior. That's what Prettier does: splits lines that are too long. See here https://prettier.io/docs/en/index.html

Related

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.

How do i prevent vscode from breaking my pasted 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:

In JSX does not create new line between tags with right indentation after heating enter

In .js or .jsx I have strange behaviour. When I have cursor between tags and press enter the vscode does not create empty line between tags and put cursor back to empty line with right indentation. It moves tag to new line. Then I have to create manually empty line between tags and indentation.
Actually is does behave as it should when tag does not have any attributes. But when ever I pass any attribute to tag it start to behave as I mentioned above. Have to mention that in .html files it behaves as expected even with attributes in tags.
I have tried to disable all extensions, install insiders versions but getting the same behaviour.

How do I get a cursor on every line in vscode

I'm trying to use the multi cursor functionality of vscode on a large(ish) file.
the file is too large to select every line individually with ctrl-alt-up or down. In sublime-text I would select everything and push ctrl-shift-l. Is there a similar thing in vscode. I've tried using a regex search for ^, but that gives me an error stating "Expression matches everything".
The command Selection / Add Cursors to Line Ends altshifti will put a cursor on every line in the current selection. (For mac use optshifti)
Tip: You can pull up the keyboard shortcut reference sheet with ctrlk,ctrls (as in, those two keyboard combos in sequence).
(For mac use cmdk,cmds)
Hold Alt+Shift and select the block. Then press End or Right button.
You get selected individual lines.
I use version VSCode 1.5.3 in Windows.
Hold Alt+Shift+i
Hold Home (fn+-> Mac) for right-most or End for left most(fn+<- Mac)
This feature is actually called split selection into lines in many editors.
Sublime Text uses the default keybinding, CTRLSHIFT L
VSCode uses ALTSHIFTI
For Atom you actually need to edit your keymap to something like this
'.platform-win32 .editor, .platform-linux .editor':
'ctrl-shift-L': 'editor:split-selections-into-lines'
Real Lines vs Display Lines
First we have to understand the difference between Real Lines and Display Lines to completely understand the answer of the question.
When Word Wrap is enabled, each line of text that exceeds the width of the window will display as wrapped. As a result, a single line in the file may be represented by multiple lines on the display.
The easiest way to tell the difference between Real Lines and Display Lines is by looking at the line number in the left margin of the text editor. Lines that begin with a number correspond to the real lines, which may span one or more display lines. Each time a line is wrapped to fit inside the window, it begins without a line number.
Cursor At the Beginning of each Display Lines:
Cursor At the Beginning of each Real Lines:
Answer to the Question
Now that we know the difference between Display Lines and Real Lines, we can now properly answer the actual question.
Hold AltShift and select the text block.
Press Home to put cursor on the beginning of every Display Line.
Press End to put cursor on the end of every Display Line.
Press HomeHome (Home twice) to put cursor on the beginning of every Real Line.
Press EndEnd (End twice) to put cursor on the end of every Real Line.
Please understand that AltShiftI put cursor on the end of every Real Line.
Install the extension Sublime Commands.
[Sublime Commands] Adds commands from Sublime Text to VS Code: Transpose, Expand Selection to Line, Split into Lines, Join Lines.
(Don't forget to add the keybinding(s) from the extensions details page to your keybindings.json)
Doesn't VS Code already have a "split into lines" command?
Yes, yes it does. However it differs from the one in Sublime.
In VS Code, when you split into lines your selection gets deselected and a cursor appears at the end of each line that was selected (except for the last line where the cursor appears at the end of the selection).
In Sublime, when you split into lines a cursor appears at the end of each line (with the same exception as in VS Code) and the selection is divided on each line and "given" to the same line.
I have the same problem, i'm used to Alt + drag to do 'box selections' in visual studio but it does'n work in code.
It seems to be impossible for now to do it differently than by selecting every single line.
However plugins should be supported soon so we will likely see a plugin for this if not implemented directly by microsoft.
From visual studio uservoice forums:
We plan to offer plugin support for Visual Studio Code. Thank you for your interests and look for more details in our blog in the coming weeks. http://blogs.msdn.com/b/vscode.
For the preview we are looking for exactly this type of feedback. Keep it coming.
Sean McBreen – VS Code Team Member

Eclipse automated code formation and Hyperlinks

I'm a big fan of the automated code formation (STRG + SHIFT + F) from eclipse. It makes your code so much more readable. However, now that I'm comenting my code, I'm getting the problem with Hyperlinks. Code formation adds line breaks anywhere in your code, so if you have e.g. a very long hyperlink it breaks into multiple lines and makes it unresolvable :(
Is there a way that eclipse doesn't format specific comment parts like Hyperlinks?
Regards,
Stefan
Code formating doesn't put line breaks in links inside a tags:
<a href=
"http://www.example.com/very-long-url">Example</a>
There is a line break just after the href=, so it may look ugly in a paragraph. Enclosing urls in <tt> tags prevents line breaks, but the url won't be a clickable link. Combine both and you get hyperlinks without line breaks. If they exceed the maximum line length, they will start on a new line though.
<tt>Example</tt>
There is also //#formatter:off to disable formatting for the following lines and //#formatter:on to enable it again.
I don't think there is any way from setting that up in the menu. The workaround is to disable block or line comment formatting in the formatter profile:
Window -> Preferences -> Java -> Code Style -> Formatter -> Edit -> tab Comments
As pointed out by Kheldar, you can always customise/extend the Java Codeformatter using the extension point, but that's probably not a one hour job for someone unfamiliar with the JDT.
Please indicate, if you need any assistance coding an extension for the formatter.