You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a keyboard shortcut (Ctrl + /) for Insert mode that runs this command: require("Comment.api").toggle.linewise.count(vim.v.count > 0 and vim.v.count or 1) because I've grown quite comfortable with the way VS Code handles comment-toggles. It works great when I have a blank (non-comment) line, because it usually inserts the comment string (in this case, //) before my cursor. Additionally, when the line is already commented and has some text after the comment, then when I toggle the comment, the text and cursor stay in the same place (i.e. stays tabbed correctly). However, when the line is commented but when there is no text, toggling the comment deletes all whitespace on the line, then in order to get my cursor in the right place again, I need to either delete the line & add a new one or press tab multiple times to get it back.
VS Code's behavior (which I like):
Nvim's behavior:
I find this quite frustrating, especially since AstroNvim (which I'm using) is configured to automatically set a new line to be commented if the line above it is already commented. So then when I want to write code, I toggle the comment to remove it and then the cursor moves all the way to the start of the line. In the end, this leaves me just backspacing a few times to remove the comment, which is quite frustrating.
Is there a way to configure Comment.nvim to not remove whitespace when I toggle a comment? Or better yet, if this is an issue with nvim itself (i.e., the same problem as in the gif below), do you know a way to configure it to not automatically delete whitespace?
The relevant VS Code setting is "editor.trimAutoWhitespace". If I set "editor.trimAutoWhitespace": true, then VS Code has the same behavior as Neovim in the above gif, which is the behavior I do not want.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I've created a keyboard shortcut
(Ctrl + /)
for Insert mode that runs this command:require("Comment.api").toggle.linewise.count(vim.v.count > 0 and vim.v.count or 1)
because I've grown quite comfortable with the way VS Code handles comment-toggles. It works great when I have a blank (non-comment) line, because it usually inserts the comment string (in this case,//
) before my cursor. Additionally, when the line is already commented and has some text after the comment, then when I toggle the comment, the text and cursor stay in the same place (i.e. stays tabbed correctly). However, when the line is commented but when there is no text, toggling the comment deletes all whitespace on the line, then in order to get my cursor in the right place again, I need to either delete the line & add a new one or presstab
multiple times to get it back.VS Code's behavior (which I like):
Nvim's behavior:
I find this quite frustrating, especially since AstroNvim (which I'm using) is configured to automatically set a new line to be commented if the line above it is already commented. So then when I want to write code, I toggle the comment to remove it and then the cursor moves all the way to the start of the line. In the end, this leaves me just backspacing a few times to remove the comment, which is quite frustrating.
Is there a way to configure Comment.nvim to not remove whitespace when I toggle a comment? Or better yet, if this is an issue with nvim itself (i.e., the same problem as in the gif below), do you know a way to configure it to not automatically delete whitespace?
The relevant VS Code setting is
"editor.trimAutoWhitespace"
. If I set"editor.trimAutoWhitespace": true
, then VS Code has the same behavior as Neovim in the above gif, which is the behavior I do not want.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions