Skip to content
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

Make line operators backwards compatible with Vim #237

Closed
critiqjo opened this issue Apr 8, 2016 · 4 comments
Closed

Make line operators backwards compatible with Vim #237

critiqjo opened this issue Apr 8, 2016 · 4 comments
Labels

Comments

@critiqjo
Copy link

critiqjo commented Apr 8, 2016

# denotes cursor position.

Part 1

(Note: there's no trailing new line at the end of line 2)

line1 of text
line2 #f text

Doing yykp results in:

line1 of text
#ine1 of textline2 of text

Part 2

#ine1 of text
line2 of text

Doing yjp will copy/paste only a single line:

line1 of text
#ine1 of text
line2 of text

Next try (with cursor at o):

line1 #f text
line2 of text

Doing yjp gives (no special handling for line at the end):

line1 of text
#ine1 of text
line2 of textline2 of text

Part 3

line1 of text
#ine2 of text

Doing dd does not delete the preceding newline character (only the text):

#ine1 of text

To delete that trailing newline, you have to do ji<BS>.

@martanne
Copy link
Owner

martanne commented Apr 9, 2016

Thanks for the detailed report!

Part 1 and 2 should be fixed by 319958e and 532f52e respectively. The latter change is strictly speaking not completely correct, but it seems good enough.

Part 3 is an unrelated display issue. The newline character is deleted, it is just that vis always displays an "empty line" at the end of the file. For example run printf "one\ntwo\n" | vis - which will result in something like:

one
two

And yes editing at the end of file should at some point probably be improved, see also #164

@martanne martanne closed this as completed Apr 9, 2016
@critiqjo
Copy link
Author

critiqjo commented Apr 9, 2016

Thanks for the quick fix!

But Part 2 is still not fixed for upwards motion ykp from the beginning of line.

And about part 3, if it is a display issue, why does the empty line go away when I do a <BS> from there in insert mode?

it is just that vis always displays an "empty line" at the end of the file.

printf "one\ntwo" | vis - does not display a newline.


An unrelated issue: if I mistakenly do printf "one\ntwo" | vis (without the trailing -), then vis gets stuck in an infinite loop. I sent a SIGQUIT and got this backtrace:

#0  0x00007f20228f142e in __libc_sigaction () from /usr/lib/libc.so.6
#1  0x00007f20230cc5f6 in _nc_signal_handler () from /usr/lib/libncursesw.so.6
#2  0x00007f20230d77ef in doupdate_sp () from /usr/lib/libncursesw.so.6
#3  0x000055a236c508f0 in ui_update (ui=0x55a238068010) at ui-curses.c:848
#4  0x000055a236c57a41 in vis_update (vis=0x55a2380761d0) at vis.c:266
#5  0x000055a236c5a7db in vis_run (vis=0x55a2380761d0, argc=1, argv=0x7fff47410e48) at vis.c:911
#6  0x000055a236c3cfdc in main (argc=1, argv=0x7fff47410e48) at main.c:2113

@martanne
Copy link
Owner

But Part 2 is still not fixed for upwards motion ykp from the beginning of line.

This is not easily fixable and requires some more thought.

And about part 3, if it is a display issue, why does the empty line go away when I do a from there in insert mode?

the file will initially be displayed like this:

#ne\n
two\n

you can place the cursor at the end of it

one\n
two\n
#

pressing backspace in insert mode will result in

one\n
two#

this can be illustrated with :set show newlines. A main difference from vim is that in vis new lines are treated like any other character and are directly addressable. Newline addressability was previously discussed.

As for the unrelated issue, without the trailing - stdin is interpreted as keyboard input. It should handle reading EOF more gracefully though.

@martanne martanne reopened this Apr 10, 2016
@martanne martanne added the vim label Apr 29, 2016
martanne added a commit that referenced this issue May 4, 2016
They behave like an inclusive motion, but only if they are also
linewise (which they are by default).

This should make `yjp` and `ykp` yank both the current and
the next/previous line when the cursor is at the start of
a line.

See also 532f52e and #237
@martanne
Copy link
Owner

martanne commented May 4, 2016

But Part 2 is still not fixed for upwards motion ykp from the beginning of line.

This should hopefully be fixed by b9d70d0.

An unrelated issue: if I mistakenly do printf "one\ntwo" | vis (without the trailing -), then vis gets stuck in an infinite loop.

This should now also be handled more gracefully. Once all data from standard input is consumed, vis will start processing regular keyboard input from /dev/tty instead.

@martanne martanne closed this as completed May 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants