-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S
/cc
doesn't auto indent on empty line
#1017
Comments
Nice catch, if the cursor is at somewhere between first char or last char, |
Not sure for what reason cursor updating in commands which invoke I take a quick look but now I'm confused, take |
@rebornix we use PositionDiffs now. We have a "beginning of line" position diff that just tells the cursor to go to the beginning of the line after the transformation is applied. We use that a few times... |
This problem is fixable once the "reindent a selection" command is added, per microsoft/vscode#19847 (comment) |
Seems |
@xiluo58 That's an interesting idea actually. To be clear to anybody who was confused as me, he's suggesting ddO. |
That works for me!
It would still definitely be nice to see the default behavior fixed. EDIT: Actually it seems like this doesn't work, seeing as though it's an insert mode key binding. I tried |
Any progress on this?
Produces
Also doesn't work when single line is indented:
Produces:
|
I agree a proper indentation should be performed of the lines. This temporary fix seems to work for me. But the previous problems by @alexozer still apply.
Not sure why the third "d" is necessary. |
Hitting Tab after cc seems to do the right thing every time. Is there a way to automate this? |
@shaunlebron It doesn't if your cursor starts after the tab position. |
@Chillee do you have an example? would like to reproduce |
@shaunlebron Take something like
where there's 2 spaces before the asdf.
and a tab adds 2 more spaces, which is not the right thing. |
any updates on this? |
Another problem with remapping to ddO is that for isolated lines (single lines with whitespace immediately above and below), there is no preceding line to base indentation off of, and so O creates the new line above with no indentation. For instance consider the following Python code:
In vim, cc would clear the line and place the cursor at the correct indentation (four space from the left margin, in this example). But in VSCode Vim, since there's no line above Python isn't the easiest language to infer desired indentation, but when the desired indentation is already given, it should be respected when using cc -- independent of any VSCode capabilities or settings. That said, I think a better temporary keybinding for a single cc would be ^C. However that's not easily repeatable -- 5cc is not achievable by repeating ^C |
Has anyone here managed to figure it out?.. Seems to be an issue still. |
Sorry to revive such an old thread - but is this really not solved yet? @rben01 s workaround of using ^ C works best for me.
Somebody got a better idea? |
There's nothing we can do about this - it's an upstream problem. After a command like Seems like these are relevant issues. Go upvote them please! |
How about using some kind of workaround until it's fixed properly upstream? It's a very annoying problem and I don't think it's good for the end user to just shove it under the rug waiting for it to potentially be fixed someday somewhere else. Like, |
Hi I have Visual Studio Code 1.43.2, vim extension 1.13.1.
This is frustrating, especially when I see this issue was raised in the year of 2016, and now it's 2020. |
I agree, it's frustrating, but then this is open source... |
Have that problem with C#. "Reindent selected lines" does not work for it, but indent adds when use "o". So I made that workaround. But it only works if upper line not empty too. "vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["S"],
"after": ["d", "d", "g", "k", "o"],
},
], |
Such kind of key binding works well indeed. |
offer a workaround for "o", which I use frequently:
|
I have noticed something. "cc" does not automatically indent, while "o" and "O" do, at least most of the time. |
@sql-koala Is this still an issue? Because I can't reproduce this. Both |
Indentation after both I write C++ and python for my job and |
S
/cc
doesn't auto indent on empty line
@J-Fields Which part of the language support handles this indentation? Is it the TextMate grammar, the formatter, the There are many languages (like Swift) which currently aren't supported very well by |
remapping cc to ddko seems to work. It seems that o formats differently from O. There might be exceptions though. |
I've been looking for answers to this for a while, and it's still broken. There are workarounds that get close, but no perfect solutions yet. The main thing I want is for |
There is always https://github.com/vscode-neovim/vscode-neovim |
When your in Normal mode and your on an empty line and the cursor is at the very left, pressing 'S' in normal Vim auto indents the line and goes into insert mode, but VS Vim doesn't seem to indent at all.
Technical details:
What happened:
Here all of those scenarios in a GIF (with tab width of 3 instead of 2)
![cc](https://user-images.githubusercontent.com/914637/27044779-187c9184-4f9f-11e7-935e-e08088751db8.gif)
Contributed by @lumio at #1828.
What did you expect to happen: Typing cc will always clear the line, indents it and cursor jumps to end of line.
How to reproduce it: See above, but typically typing cc on different col positions.
The text was updated successfully, but these errors were encountered: