ESLint indentation issue with commented lines - visual-studio-code

There is an indentation issue with comment lines. To give an clear idea please take look on the following screenshot with descriptions.
In my VS code I have configured to Auto saved with ESLint formatting.
In here I have two commented lines of code. (line 49 and 50) with proper indentation.
And then when I save the page, starting from line 47 to 57 (the code block which contains the commented code) indentation become like the below screenshot.
Even after the fixing these issue, it continuously happens.
UPDATE:
With comment lines
Without comment lines

Related

Neovim remap for vscode for commenting doesn't work

This is my current code
map z, <Cmd>call VSCodeNotifyRange('editor.action.commentLine', getline('.'), getline('.') + v:count1, 1)<CR>
Usage of VSCodeNotifyRange used as explained in the Neovim extension's readme:
What I'm trying to do: I pass a number to the remap, for example 5z,
The current line and four next lines are selected in vscode, and then commented out
What's happening: nothing gets commented out, and I get jumped to the line I specified the number to
So when I use 5z, I end up on line 5 (absolute). When I use 10z, I end up on line 10, and so on
I imagine this is a syntax issue, any help would be appreciated

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:

Comment line command that inserts // at the start of the line, not indented

By default, commenting a line in Visual Studio Code (with Ctrl+/) adds the // such that it is indented as far as the code being commented.
I prefer seeing code comments blocked out at the margin (column zero). Is there a way to configure this behaviour?

Why are these line heights varied?

Note the attached screenshot from my Emacs 24. It is in Fundamental mode, no visual line mode is turned on, and I don't think I've turned on any word wrap mode either:
You can clearly see that the lines at the bottom are closer together than the lines at the top, but I have no idea why.. it's all just text? Why is emacs doing that?
This is the mode I am in:
Update: It just occured to me that perhaps this issue is that I am copying/pasting this text into emacs as I take notes from a PDF I am reading. Perhaps emacs is somehow getting formatting based from this copy/paste? I thought this was a text-only file with no formatting, but perhaps that is not true?
The issue is due to unusual quote symbols, both apostrophes and quotation marks, that are affecting the line heights. Removing these and using "normal" quote marks resolves the issue.

how to freely format comments in cc-mode

I'm quite new to cc-mode and I'd like to configure it to allow me to freely format and use tabs in multiline comments. This is important to me because I want to use cog.py in my source file and need to be able to format the python source in the comment correctly. I'd be ok with comments not beeing autoindented at all, however I'd like to keep auto indenting the rest of the source code.
Example:
...
/*
[[[cog
import cog
for x in ['a','b','c']:
>cog.outl(x)
]]]
*/
...
In the line marked with > I'd like to press TAB to indent the line. cc-mode simply does nothing at all if i do so. I could use spaces there (which is inconvenient) but every (semi-)automatic re-indentation of this block would cause the spaces to vanish and therefore the python code to be incorrectly indented (which is what happens if i happen to press tab somewhere on this line after indenting it with spaces).
I tried to start emacs without my .init to be sure this is default behavior and not modified by my configuration so far. I've done google searches and read the documentation of the cc-mode variables / functions I stumbled upon (cc-mode online docs) while searching for a solution (i.e. c-indent-comments-syntactically-p, c-indent-command, c-tab-always-indent,...) but none of these seemed to solve my question.
EDIT1:
Thanks to abo-abo's idea of a "multi-major-mode" setup i've stumbled upon mmm-mode and have set up automatic switching to python mode for a cog section, which fixes most of my problems.
The only remaining problem is reindenting the whole file or a region containing a cog section. Can I somehow tell cc-mode to not change anything in comments while reindenting the file? mmm-mode + that would be a perfect solution for me.
You can use M-i to force a tab indent on the lines that you want, so you can use it to indent your comments.
You can also change your comments to use // instead. Just select your python code snippet, and do M-x comment-region:
// def foo(x):
// print 'hi'
Then the autoindent won't mess up your indentation.