-
Notifications
You must be signed in to change notification settings - Fork 265
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
Optional vi-like cursor behavior when leaving insert mode. #54
Conversation
Thanks! If possible I would like to avoid introducing options like Having said that, why do you prefer it? What is the reason vi(m) did it that way? Intuitively leaving insert mode and then entering it again should not change the cursor position. |
No idea why they would do it that way, but it's muscle memory to expect it to go left one after leaving insert. :) I'm fine with this setting being available, but I don't care if it isn't implemented either. |
Since newlines are not addressable in vim, when you are appending to a line in vim the cursor is temporarily over an invalid character (and hence the move back after an insert / append). See http://stackoverflow.com/a/17975729. The newline addressability decision makes the vim / vis interfaces diverge. On a single empty line, in vis The '$' operator in vis can actually move you left if you are on a newline. If newline addressiablity is kept, |
The original impetus for raising issue #42 was that it did not match my expectations coming from vim (a muscle-memory thing, as @greduan said). The more I think about it though, I don't need or even really particular care about that UX nuance. As @trengrj mentioned, newline addressability does introduce other interface divergences, and those divergences are the ones that worry me a bit more. For example:
Those are just a handful of edge cases that I was able to find in about 5 minutes of playing around. Now it may be entirely possible to resolve these inconsistencies while maintaining newline addressability, but it does seem to be a common cause of a number of these UX 'bugs'. |
I agree that the newline addressability causes some differences compared to vim. The question then is whether they are harmful or not. I'm yet undecided and in general quite like it. It certainly is a controversial thing, even one of the first comments after the public announcement of vis was about it.
Is this a bad thing?
True, but does it really matter? Why would you use
I tend to agree, that is why I implemented :set show newlines=1. If you enable this setting you will see that you can in fact delete the last newline of a file. What you are probably refering to is the (illegal) position after the end of file where you would insert new text. I agree that in this case It is the way it is because I wanted to avoid special cases. Another reason might be that I rarely edit files at the end and therefore it didn't bother me too much so far. |
Changing the cursor position when leaving insert mode would break the the dot command which is implemented by replaying an implicit macro which might repeatedly switch in and out of insert mode (see also #44). I still like newline addressability and I'm thus closing this. If someone sends an updated patch which works with the repetition code, this can be reconsidered. |
Because this pull request is regularly referenced when discussing newline addressability related issues, here a quick update:
This is no longer the case.
Due to popular demand (e.g. #287, #295) this was changed to match the vim behavior. Repeatedly switching in and out of insert mode is still idempotent in the sense that the cursor position remains unchanged. This is the desired behavior for vis and there currently exist no plans to change it. The same applies for newlines which are still directly addressable. |
I would love for this feature to be implemented. This behavior is the only reason feel the urge to switch to nvi. |
This addresses #42 in a non-intrusive way. When the
vicursor
option is set, the cursor will move one column to the left upon exiting insert mode. Since newlines are addressable and appear before the first column of the next line, the exception to this behavior is when insert mode is left while the cursor is on the first column of a line.I am not sure that putting this functionality in config.def.h is the right approach, but it works for me.