Closed TheBB closed 7 years ago
Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):
Well, the behavior depends on whether "abc" is the last line in the buffer (and if it's finished by a newline character). If the buffer content is
abc
(and there is no final newline character!) the result is
abbcc
in both, Vim and Evil. Similarly, if "abc" is not the last line, e.g.
abc
xxx
then the result is
abbc
c
xxx
again in both Vim and Evil. Depending on that final newline in the buffer (which is usually not visible in Vim but it is in Emacs due to different representations of the buffer content), the behavior may be slightly different. But IMHO, this small difference is not worth the effort.
Original comment by w_glass (Bitbucket: w_glass, GitHub: Unknown):
There is a difference in behavior between vim and evil-mode. Start with abc
on the buffer, cursor over "b". Do v$yp
.
In Vim 7.2.445 and 7.3.429 this results in
abbcc
But in evil-mode this results in
abbc
c
Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):
I tested it in v7.3.62 and v7.2.108 in both, the terminal and the gtk frontend and the result is always the same, v$
selects the final newline. Consider a buffer with content
abc
def
ghi
and cursor placed on the "b" in the first line. Executing v$d
results in
adef
ghi
because v$
selected the final newline which is therefore deleted (which is essentially the reason why the final newline can be selected anyway). Perhaps your vim behaves differently but as long as mine does not behave as yours and you do not provide a convincing example (i.e., a full example with buffer contents and key strokes) or an excerpt from vim's documentation confirming the behavior you describe, the current implementation won't be changed.
Original comment by York Zhao (Bitbucket: york, GitHub: york):
In my Vim v7.3 with all default configuration, "v$" selection doesn't include the line end character. I still believe this is the correct behavior. Since you said your Vim v7.2 works the other way, I guess this should be configurable in Vim, therefor, it makes sense to make it configurable in Evil as well.
Original comment by York Zhao (Bitbucket: york, GitHub: york):
The problem is not with the "$" command itself, in fact the "$" command works fine by being able to adjust the cursor back for one position at the end of line. However, it is the "v$" that is not working properly, at least not in consistent with the behavior of "$" command in that "v$" includes the line end character into the selection which is not preferred. I have just tested in Vim where "v$" has excluded the line end character from the selection which is in consistent with the behavior of "$" command. Therefor, I think the current behavior of "v$" in Evil is not in consistent with that of in Vim.
Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):
The current behavior is consistent with ViM which behaves as if evil-move-cursor-back
is non-nil, i.e. moving the cursor back when exiting insert-state, not allowing to put cursor on the final newline of a non-empty line but allowing to select the newline in visual state. Therefore the requested behavior would break compatibility with ViM.
Of course, one could add yet another configuration option, but I vote against this as it would be just another complication of evil. Instead you can easily write your own replacement:
(evil-define-motion my-evil-end-of-line (count)
:type inclusive
(evil-end-of-line count)
(evil-adjust-eol))
(define-key evil-motion-state-map "$" 'my-evil-end-of-line)
Originally reported by: York Zhao (Bitbucket: york, GitHub: york)
When the value of `evil-move-cursor-back' "is 't', "$" command will move the cursor to last character of the line rather than to the line end character which is good, however, "v$" will still select the line end character which is inconsistent and less useful.