issue subtituting new lines

17 views
Skip to first unread message

Eli the Bearded

unread,
May 19, 2020, 1:40:41 PM5/19/20
to vim...@googlegroups.com
I use several versions of vim throughout the day, all inside xterms, and
some inside tmux running in an xterm. Some versions of vim I have
noticed break my long standing way of adding newlines in a :s///
substitute command.

To make all %% sequences turn into a new line, what I'd type is:

colon percent s slash percent percent slash ctrl-v ctrl-m slash g enter

And that would look like this in vi, nvi, and vim up until recently:

:%s/%%/^M/g

On the versions that break that, it instead looks like this:

:%s/%%/^[[27;5;109~/g

Which will not (does not) provide the subtitution I want.

I have found the vim I'm using on NetBSD inside xterms without tmux
do this, but that same vim on NetBSD inside xterms with tmux does not
do that.

:version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jan 7 2020 09:55:54)
Included patches: 1-2200
[...]

:r! uname -sr
NetBSD 8.1

Inside tmux, $TERM is "screen", outside tmux $TERM is "xterm",
$XTERM_VERSION is "XTerm(330)". Figuring out the exact differences
between the screen and xterm terminal definitions is not something I
want to dive into.

If I use vim.old on that same system, the substitute works inside and
outside of tmux. On vim.old:

:version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 11 2019 15:16:00)
Included patches: 1-1517

Is this a known bug that has been fixed in a patch after 2200? If so,
I'll request the vim here be updated. If not, can this be fixed? (And
then I'll request the update.)

thanks,
Elijah

Christian Brabandt

unread,
May 19, 2020, 1:58:55 PM5/19/20
to vim...@googlegroups.com
A feature or a bug i suppose. What you are seeing are the effects of the
modifyOtherKeys feature of Vim and xterm (see :h modifyOtherKeys).

I am not sure why it happens for you when pressing CTRL-V in command
line mode, it does work for me as expected, unless you accidentally
pressed Shift-Ctrl-V instead of Ctrl-V

To disable it, set the t_TI and t_TE terminal settings to the empty
string:

let &t_TI=""
let &t_TE=""


Best,
Christian
--
Das Beste in einem Menschen ist das, was er selber nicht kennt.
-- Jean Paul

Eli the Bearded

unread,
May 19, 2020, 5:58:58 PM5/19/20
to vim...@googlegroups.com
Christian Brabandt <cbl...@256bit.org> wrote:
> On Di, 19 Mai 2020, Eli the Bearded wrote:
>> And that would look like this in vi, nvi, and vim up until recently:
>> :%s/%%/^M/g
>> On the versions that break that, it instead looks like this:
>> :%s/%%/^[[27;5;109~/g
> A feature or a bug i suppose. What you are seeing are the effects of the
> modifyOtherKeys feature of Vim and xterm (see :h modifyOtherKeys).
>
> I am not sure why it happens for you when pressing CTRL-V in command
> line mode, it does work for me as expected, unless you accidentally
> pressed Shift-Ctrl-V instead of Ctrl-V

No, I was quite careful in what I typed. But reading :h modifyOtherKeys
leads me to understand what is going on.

If, when modifyOtherKeys is enabled, instead of:

colon percent s slash percent percent slash ctrl-v ctrl-m slash g enter

I type:

colon percent s slash percent percent slash ctrl-v enter slash g enter

I get the:

:%s/%%/^M/g

output I expect. xterm and vim are trying to represent a <ctrl-m> as
different than <enter> with that setting and I'm seeing the results. But
since <enter> is what I really want, actually using <enter> works.

I'll have to mull over if I consider this an improvement or not.

> To disable it, set the t_TI and t_TE terminal settings to the empty
> string:
>
> let &t_TI=""
> let &t_TE=""

Why that syntax instead of "set t_TI=|set t_TE="? I'm already using
"set t_Co=0" in ~/.vimrc to disable colors. (Specifically it sets
the number of colors available to zero.) In testing, both forms seem
to work in .vimrc, and neither seems to work from the ":" prompt --
even after I ":!ls" as suggested by the help page.

Thanks for finding that.

Elijah

Ken Takata

unread,
May 19, 2020, 10:03:19 PM5/19/20
to vim_use
Hi,
I think this behavior is fixed in 8.1.2350.
Both Ctrl-V Ctrl-M and Ctrl-V <Enter> will input ^M now.

Regards,
Ken Takata
Reply all
Reply to author
Forward
0 new messages