Tuesday, November 12, 2019

Re: Un-POSIX-like behavior of join command

On Tue, Nov 12, 2019 at 8:47 AM Brennan Vincent <brennan@umanwizard.com> wrote:
>
> When joining a line that is followed by an empty line (or one with only
> spaces), POSIX specifies that it should be deleted without the current
> line being affected. See the section "Join" in
> https://pubs.opengroup.org/onlinepubs/9699919799/ .
>
> However, vim appends a space to the current line in this case. For
> example, if line 1 is "foo", and line 2 is blank, after executing :1j
> line 1 will be "foo ", as can be seen by executing the following (`ex`
> is provided by `vi` on my system)
>
> $ echo -e 'foo\n' > test.txt && echo -e '1j\nwq' | ex test.txt && wc -c
> test.txt
> 5 test.txt
>
> nvi/nex give the POSIX behavior:
>
> $ echo -e 'foo\n' > test.txt && echo -e '1j\nwq' | nex test.txt && wc -c
> test.txt
> 4 test.txt
>
> Is this a bug, or intentional?

If you want Vim to behave as close as possible to "what Vi must do"
according to POSIX, you should set the $VIM_POSIX environment
variable: for instance (in a bash shell) by running Vim as

VIM_POSIX=1 vim -u NONE

Otherwise Vim will intentionaly deviate from some of the "rules" set
by POSIX. For details, see:
:help posix
:help 'cpoptions'
This latter one is quite long, check all flags other than aABceFs
including, but not limited to (at the bottom of the list) all POSIX
flags.

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXs78mRCA2zSzBOvMpfnCMLieT3%2BYOw319oYGNp%3DJgSNxg%40mail.gmail.com.

No comments:

Post a Comment