-
Notifications
You must be signed in to change notification settings - Fork 280
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 breaks visual-line-mode #188
Comments
Original comment by Michael Markert (Bitbucket: cofi, GitHub: cofi): I think your code could be a lot more easier considering there is If I understand Frank's thoughts at the vim-mode issue correctly it's less about how to select the text but how to deal with it conceptually. |
Original comment by Titus von der Malsburg (Bitbucket: tmalsburg, GitHub: tmalsburg): The point of my code is that it attempts to solve this conceptual issue once and for all by equating visual lines with real lines. For instance, if you From the perspective of the user, the fact that visual lines are not real lines should not matter at all, because it's the very purpose of visual-line-mode to give visual lines the semantics of real lines. If you switch off visual-line-mode, everything should of course behave as it usually does in Vim. That means that the above code would have to be amended to do this wrapping and unwrapping business only if visual-line-mode is switched on. (Edit: duh, I just see that the code already does that.) I hope that clarifies my idea, sorry if the first post was confusing. |
Original comment by sampablokuper (Bitbucket: sampablokuper, GitHub: sampablokuper): @tmalsburg, thank you for reporting this issue, which has been bugging me for a while! Thank you also for your draft patch. It would be great for this to be fixed, along the lines you describe. As a possible alternative to fixing this directly within Evil, have you considered creating an Emacs plugin? (Maybe you could call it "evil-intuitive-visual-lines" or suchlike?) Regardless of approach, all the better if it the fix is done in a way that allows it to be easily integrated into Spacemacs, perhaps even as part of the default Spacemacs install. (I'm not yet sufficiently competent at Emacs Lisp to do this work myself, sorry!) |
Here are some things that appear to work after some short tests (with evil from MELPA and up-to-date Emacs from development master branch):
However, a whole bunch of other things do not work at all or incorrectly:
Both lists above are likely incomplete. One would have to go through the vim manual for a complete list of operations that are affected by this. Regarding implementation: I had a quick look at the code behind |
@TheBB, I apologize for not responding to your comment from 2016. I must have overlooked the notification. Responses below.
Perhaps an implementation as a package is possible but it might be complicated and not the most natural solution as this package would have to modify core evil behaviour not just add behaviour. Also, since we have
I agree but should say that I'm not using Spacemacs myself and I'm not really familiar with it. |
@tmalsburg This is a migrated issue from Bitbucket. The actual authors of the migrated comments are in the text, so that's not mine. I'll reopen. |
Thank you (also for the clarification). |
Hello, I am very much interested in this, as this is still one of the main reasons making me not entirely happy with emacs. However, I don't just want to complain here, but rather offer my assistance in resolving this issue, if there's interest. I don't have any experience in elisp apart from writing a 104 line emacs config right now, so I could use some assistance (I've used Doom until recently, and am just starting to create my own config from scratch). I'd also be interested to hear other people's opinions on what they think the behavior of |
@tmalsburg Something else for the 'not working correctly' list:
|
I have a related issue with Unfortunately At the moment there is a nasty hack that can be used to partially obtain this behavior which is to However, this is exploiting some strange persistent state and is completely unreliable. Also, it does not fix the behavior of operations such as |
I understand your point and use case, but keep in mind that visual-line-mode is primarily attractive for writing text not so much for code. Personally, I'd not use visual-line-mode in any code buffers because there I want to manage line breaks manually and I need the buffer to show exactly what's in the file without any extra virtual line breaks. For instance, visual-line-mode could totally mess up the apparent syntax of Python source files. However, if you write text, it's perfectly reasonable for More generally I think it's best to implement visual-line-mode in evil such that all line operations act on visual lines instead of buffer lines. This way visual-line-mode behaves perfectly predictably. If visual-line-mode mode would change only some line operations to visual lines but not others, that will be confusing, difficult to learn, and there will be potential for endless debates about which operations should act on visual and which on buffer lines. Doesn't seem desirable. Having said that, it would also be nice if it was possible for users with different preferences to choose and pick. |
The main place that I run into these issues is in org-mode buffers where I have text and code at the same time. Most of the time I manually wrap my blocks, but I can't always, especially when there are urls that are quite a bit longer than my fill column setting. There are also cases where I need retain a single line e.g. github issues and various other web text fields, where manual line wrapping has nasty interactions with the automated rendering algorithms those fields employ. |
@tgbugs what about this (defun evil-redo-no-respect-visual-line ()
(interactive)
(undo)
(let ((evil-respect-visual-line-mode nil))
(evil-repeat 1))) Bind it to a key, to quickly redo your last evil command on a logical line instead of a visual line. |
Originally reported by: Titus von der Malsburg (Bitbucket: tmalsburg, GitHub: tmalsburg)
In Evil, line operations always affect buffer lines instead of visual lines. This behavior is consistent with Vim. While I think that consistency is important, the reason why people use Evil instead of Vim is that they would like to take advantage of features provided by Emacs. One such feature is visual-line-mode. The purpose of visual-line-mode is:
In other words, the fact that visual lines are not buffer lines is supposed to be completely transparent to the user. Evil breaks visual-line-mode because it operates on buffer lines regardless of whether visual-line-mode is on or not.
Visual-line-mode may not be important for people who mainly write code, because in code, you want to manage line breaks yourself. However, when writing prose, visual-line-mode can be essential. One reason why I left Vim was that I was sick and tired of doing
gqap
hundreds of times a day. Commands that I would like to see working with visual lines instead of with buffer lines are of coursedd
andyy
, but alsoI
andA
, etc.What are possible solutions? I guess, one possibility would be to change all kinds of Evil commands to deal with visual lines instead buffer lines when visual-line-mode is switched on. This is what I currently implemented for some important commands. However, this leads to a lot of changes and messy code. Another possibility may be to let Evil always operate on visual lines irrespective of whether visual-line-mode is switched on or not. The obvious draw-back is that Evil's behavior would then be inconsistent with Vim's when visual-line-mode is turned off.
A more elegant and more correct solution might therefore be the following: The idea is to enclose line-operations in a function that does the following:
fill-region
.dd
,yy
,I
,A
, ...).fill-region
.For this to work properly,
fill-column
has to be set to the current width of the window (in characters). Filling should then not change the appearance of the text but simply replace visual line breaks by real line breaks (i.e. "\n" characters). So the user shouldn't notice what is going on. Here's some code to illustrate what I mean:This code may break some things like macros (
q
and friends) but perhaps this can be dealt with. In case that this solution can be generalized to handle other operations likeyy
anddd
as well, this may be a nice approach because it doesn't require changes in too many places. The whole issue is rather beautifully factored out from the actual line operations. The line operations themselves would be agnostic to the whole issue and would not have to deal with visual lines at all.Frank considered a similar solution for VimMode. See https://bitbucket.org/lyro/vim-mode/issue/33/visual-line-mode
I think that having Evil play nicely with visual-line-mode would be a major improvement.
The text was updated successfully, but these errors were encountered: