emacs-evil / evil

The extensible vi layer for Emacs.
GNU General Public License v3.0
3.35k stars 283 forks source link

Appending text in block-visual-mode does not work as in VIM #120

Closed TheBB closed 7 years ago

TheBB commented 12 years ago

Originally reported by: Anonymous


I'm using Emacs 24.0.93.1 and the latest revision of Evil (95e0dde27cfe).

Reproduction steps are as follows.

Suppose the active buffer has the following content:

|aaa
bbbbbb
ccc

Where | is the location of the point. Then do the following:

Then the buffer contains the following:

aaa SOMETEXT
bbb SOMETEXTbbb
ccc SOMETEXT

Instead of the expected (at least using VIM v. 7.2):

aaa SOMETEXT
bbbbbb SOMETEXT
ccc SOMETEXT

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Make `evil-append' handle block insertion extended to eol

If the visual state is block and the temporary goal column is large then the insertion is done using `evil-append-line' which appends to text to the end of each line. This closes issue #120.

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Use evil-apply-on-rectangle' inevil-yank-rectangle'

This allows yank extended block region until the eol. This addresses issue #120.

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Ensure `evil-delete' respect blocks until eol

In order to support deletion of blocks that are extended to the end of each line we may not use delete-rectangle' but usedelete-region' in conjunction with `evil-apply-on-block'. This addresses issue #120.

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Add `evil-apply-on-rectangle'

This is the same as `apply-on-rectangle' but may extend the region to the end of each line. This happens if the last command has been a line motion and temporary-goal-column is very large. The the actual end column of the operation is that largest column of the covered block. This addresses issue #120.

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Make `evil-apply-on-block' respect extension of block to eol

When the last command has been a line-motion and the goal column is very large then the function is applied on each line up to the end of that line. This addresses issue #120.

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Make visual state show region extended to eol after $

If the current command is a line-motion and the goal column is large then the visual region is extended to the end of each line. This addresses issue #120.

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Add `evil-track-eol' variable

If this variable is non-nil (the default) a line move (motion j or k) after an end-of-line (motion $) keeps point at the end of the line. The Emacs customization variable track-eol' is not sufficient because of the different interpretation of end-of-line of plain Emacs and Evil. This is achieved by settingtemporary-goal-column' to a large number and predicting that this-command' isnext-line' when `evil-end-of-line' is called. This addresses issue #120.

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Issue #145 was marked as a duplicate of this issue.

TheBB commented 12 years ago

Original comment by Anonymous:


I see. Using the linewise visual state instead works great and is a fine workaround.

Thank you so much for the quick reply.

TheBB commented 12 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


(Reply via fran...@mathematik.tu-chemnitz.de):

Yes, that's right. But you can currently use linewise visual state to achieve the same result (use V instead of ).

Btw, the same works with "I" instead of "A". The idea behind this logic was that I and A in linewise visual state should work on, well, whole lines, so A means the command A on each line, I means the command I on each line (i.e. insert before the first non-blank, not necessarily in column 1). I hope this is okay as a workaround in the meantime.

The visual block state issue is not completely trivial (though, the insert part is not very difficult) because it also requires a special visual selection (the "block" is not rectangular in this case but extends to the end of the line so this needs a more careful handling).