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
cc doesn't put the cursor at indent if on empty line #881
Comments
The behavior I see in VsVim mirrors what I see in gVim. I think we have a different setting toggled. I actually see a behavior difference after the 'o' step at the top. My cursor will appear on the same column as the Can you run |
Does VsVim account for indentation settings in VS? If so, here are mine (under Options -> Text Editor -> C# -> Formatting):
I don't know if this matters either, but I have indenting set to Smart, size 4, Keep tabs. HTH |
Yeah autoindent does appear to be the difference. Once I set that + saved it as a .c file I could get the behavior you were seeing. Took a quick glance at the code and it does appear to be an issue with empty lines. The code doesn't respect In general VsVim prefers Visual Studio indent over Vim indent. This can be overriden by disabling the option This mostly works out. Unfortunately in 2010 though not all languages provide good APIs for indenting services. C# has the best, VB has practically none and C++ is a roll of the dice. I believe it gets better in VS11 but haven't played around enough yet to see how much. Will try to squeeze this fix into 1.3 |
Played around a bit more and this behavior is actually keyed off of |
You're right, I managed to reproduce it too after you mentioned it with In normal settings, Vim seems to be automatically setting |
Hi guys,I met with the same issue. backspace="indent,eol,start"
hlsearch
ignorecase
incsearch
autoindent |
@lookforit at the moment no. This behavior is actually a part of |
This simple workaround gives me the behaviour I expect from vim:
|
This would still be a nice-to-have. My intuitive sense is that the 'cc' to clear a line and begin editing should begin at the same indent level as creating a newline. Is there an internal Vim/VS reasoning that this shouldn't be so? I may tackle it as an inroad into working with the project. |
The solution to this problem was superficially nothing more than "do for VsVim was already doing the correct thing for so-called "vim indent," the kind of indent VsVim uses when there is no language service available. In order to add tests for this issue, I had to add infrastructure to the tests to simulate a language service. So the disconnect was that all the existing tests use "vim indent" but 99% of users are using "host indent", i.e., are editing files where Visual Studio provides an indent service. To further complicate the problem, there was a bug that nobody ever reported with "vim indent" where it didn't work correctly when tabs were not being expanded (see issue #2302). Again, from a practical point of view nobody uses "vim indent" so upon reflection this isn't that surprising. |
cc deletes the current line and places the cursor in insert mode (the 'autoindent' option determines its position).
VsVim doesn't always put the cursor in the right position. The one case I consistently managed to reproduce it is if you cc on an empty line it will place the cursor at the first column rather than at the indent.
Consider the following starting C# code ([ ] is the ncursor, | the icursor):
Press
o
to open line below:Now press
Esc
:Now press
cc
. This is where Vim and VsVim differ: Vim will place the cursor indented within the Bar:while VsVim will place it at line 0:
Alternatively, use this code:
In both Vim and VsVim a single
cc
will place the cursor in the indented position, butcc<Esc>cc
will place the cursor at column 0 in VsVim (while Vim puts it at the right indent).The text was updated successfully, but these errors were encountered: