-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Evil/Vim's $
command and end-of-line behavior
#2525
Comments
That's a very tricky situation. I see no satisfying solution, even a blend of the two behaviors is not ideal. |
This implements @darkfeline's Vim and Evil have separate motions for beginning of line, too: (evil-define-motion evil-last-non-blank (count)
"Move the cursor to the last non-blank character
on the current line. If COUNT is given, move COUNT - 1
lines downward first."
:type inclusive
(evil-end-of-line count)
(re-search-backward "^\\|[^[:space:]]")
(setq evil-this-type (if (eolp) 'exclusive 'inclusive)))
(define-key evil-motion-state-map "g$" 'evil-end-of-line)
(define-key evil-motion-state-map "$" 'evil-last-non-blank) |
Also, the new behavior makes hitting |
@herbertjones That's unfortunate. You can always use |
I'm unconvinced by my own suggestion, and I've reverted to standard evil behavior, as god intended. |
@TheBB "standard evil behavior" Do you mean Vim's behavior or the current behavior? |
I mean Vim's behavior, with |
My vote is for the original Vim's behavior of |
We should be ok if we just advice $ to go backward one character when beyond eol is allowed. To my mind, consistency of evaluating sexp is as important as $ original behavior. A partial solution is a no go. I'll see if I can get it upstream. |
+1 for original vim behavior of $. |
Emacs is used for lots of editing tasks besides evaling sexps, and this is a pretty major departure from vim behavior. If it's possible to make this non-default and/or restricted to modes that require it, that would make longtime vim users like me a lot happier. |
Don't worry :-)
|
here's a solution to the eval-last-sexp problem. I just tested that it works (defun eval-end-of-sexp (arg)
(interactive "P")
(save-excursion
(forward-char)
(eval-last-sexp arg))) |
It works but this is not what needs to be fixed. The inconsistency is that in elisp the point must be on the closing parenthesis whereas in other lisps it is still the vanilla behavior where the point must be put behind. I go the vanilla behavior route which is the way I find the most natural and viable in the long run, maintenance wise. |
but then you can't eval a sexp without a space at the end no? |
You can with |
then why this 41459be? |
I'm the contributor of |
Obviously both concerns are equally important but |
Ok, thanks. What I was suggesting is that it seems strange to alter the behavior for one (yes important) function, when it's easy to come up with alternatives that do what you want. |
@justbur you can PR your hack in the meantime. |
@justbur what is easy ? The issue is that we cannot move the point beyond the last character in evil. |
Well we can with |
Sorry to intrude. I can adjust to whatever the default becomes and am not concerned. I was just offering a different way to approach the problem, instead of change the behavior of evil use a different but equally as functional eval function. |
But the default behavior of evil/vim is the problem :-D |
I agree that either option causes problems, but as far as a default is concerned I'm willing to bet that the average spacemacs user is comfortable with the vim way of doing things and doesn't do a lot of lisp coding. For the others, it's very easy to use |
I don't know what we are arguing here, we reverted eol back to nil for the exact reason you mentioned. When we have consistent evil motion while being able to go past the last char I'll re-enable it. As I said there is no partial solution. We have to have both. |
I don't know either. I'll stop :-) |
So after digging evil the conclusion is: we keep the Vim behavior and we will advise the eval functions of the other lisps to be able to put the cursor on the closing parens to eval last sexp. This is the opposite solution of what I wanted. So in Normal state the point must be on the closing parens. Seems consistent and should be POLA enough. The thing is to have the same behavior in any mode so we will advise all the lisp dialects to follow what is done in Evil. |
Is this still on the 0.104 milestone after 41459be? |
Not really. I guess the 0.104.0 is almost ready, I wan't to rewrite a bit the README.md to make is shorter and some pompous stuff in DOCUMENTATION.org (especially at the end). |
I close this discussion and open a new one for the adapting clojure etc... |
I noticed recently that Spacemacs now allows the cursor to move "beyond" the end of the line, which Vim/vi does not traditionally allow. I think this change is great because some Emacs functionality assumes the ability to do so, such as
eval-last-sexp
.However, I'm not entirely sure if the
$
command should move beyond the end of the line or to the final character in the line. Currently, it does the former, but coming from Vim I am used to the latter. In particular, with the former,$i
and$a
both do the same thing, appending to the end of the line, but with the latter, there's the option of doing$i
to insert before the last character in the line. However, the former is useful in conjunction with, e.g.,eval-last-sexp
. Perhaps$
should work like in Vim and a newg$
command for moving beyond the end of a line?I'm interested in hearing what other users think about this.
The text was updated successfully, but these errors were encountered: