[vim/vim] Incorrect indentation when pasting indented text from insert mode with `autoindent` enabled (Issue #11553)

12 views
Skip to first unread message

Melker Österberg

unread,
Nov 15, 2022, 11:42:16 AM11/15/22
to vim/vim, Subscribed

Steps to reproduce

  1. > vim -u DEFAULTS -c "set autoindent"

  2. Enter insert mode and paste the following with <C-r>+ (assuming that you have copied it to your clipboard register)

    	foo
    	bar
    	baz
    
  3. Pasted text looks like this:

    	foo
    		bar
    			baz
    

If I disable autoindent, i.e. run vim -u DEFAULTS, the text gets pasted with the correct indentation.

Expected behaviour

Text gets pasted like this:

	foo
	bar
	baz

Version of Vim

9.0

Environment

Operating system: Manjaro Linux x86_64
Terminal: Alacritty
Value of $TERM: tmux-256color
Shell: zsh

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11553@github.com>

Gary Johnson

unread,
Nov 15, 2022, 12:23:11 PM11/15/22
to reply+ACY5DGCAK3BERMJSRA...@reply.github.com, vim...@googlegroups.com
On 2022-11-15, Melker Österberg wrote:
> Steps to reproduce
>
> 1. > vim -u DEFAULTS -c "set autoindent"
>
> 2. Enter insert mode and paste the following with <C-r>+ (assuming that you
> have copied it to your clipboard register)
>
> foo
> bar
> baz
>
> 3. Pasted text looks like this:
>
> foo
> bar
> baz
>
> If I disable autoindent, i.e. run vim -u DEFAULTS, the text gets pasted with
> the correct indentation.
>
> Expected behaviour
>
> Text gets pasted like this:
>
> foo
> bar
> baz

That is expected behavior. From ":help i_CTRL-R":

The text is inserted as if you typed it, but mappings and
abbreviations are not used. If you have options like
'textwidth', 'formatoptions', or 'autoindent' set, this will
influence what will be inserted. This is different from what
happens with the "p" command and pasting with the mouse.

To get the behavior you want, use <C-r><C-o>+. From ":help
i_CTRL-R_CTRL-O":

Insert the contents of a register literally and don't
auto-indent. Does the same as pasting with the mouse
|<MiddleMouse>|.

Regards,
Gary

vim-dev ML

unread,
Nov 15, 2022, 12:23:30 PM11/15/22
to vim/vim, vim-dev ML, Your activity

On 2022-11-15, Melker Österberg wrote:
> Steps to reproduce
>
> 1. > vim -u DEFAULTS -c "set autoindent"
>
> 2. Enter insert mode and paste the following with <C-r>+ (assuming that you

> have copied it to your clipboard register)
>
> foo
> bar
> baz
>
> 3. Pasted text looks like this:

>
> foo
> bar
> baz
>
> If I disable autoindent, i.e. run vim -u DEFAULTS, the text gets pasted with
> the correct indentation.
>
> Expected behaviour
>
> Text gets pasted like this:
>
> foo
> bar
> baz

That is expected behavior. From ":help i_CTRL-R":

The text is inserted as if you typed it, but mappings and
abbreviations are not used. If you have options like
'textwidth', 'formatoptions', or 'autoindent' set, this will
influence what will be inserted. This is different from what
happens with the "p" command and pasting with the mouse.

To get the behavior you want, use <C-r><C-o>+. From ":help
i_CTRL-R_CTRL-O":

Insert the contents of a register literally and don't
auto-indent. Does the same as pasting with the mouse
|<MiddleMouse>|.

Regards,
Gary


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11553/1315638636@github.com>

Melker Österberg

unread,
Nov 16, 2022, 2:22:48 AM11/16/22
to vim/vim, vim-dev ML, Comment

Closed #11553 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issue/11553/issue_event/7820756729@github.com>

Melker Österberg

unread,
Nov 16, 2022, 2:22:48 AM11/16/22
to vim/vim, vim-dev ML, Comment

I didn't know of this distinction, thank you very much!


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/11553/1316495027@github.com>

Reply all
Reply to author
Forward
0 new messages