auto indent

24 views
Skip to first unread message

Eliza

unread,
Aug 27, 2019, 12:29:16 AM8/27/19
to vim...@googlegroups.com
Hi,

How to disable auto indent globally when pasting a piece of code into VIM?

thanks

wsd...@163.com

unread,
Aug 27, 2019, 4:34:21 AM8/27/19
to vim...@googlegroups.com
you can use set paste

Eliza

unread,
Aug 27, 2019, 4:54:18 AM8/27/19
to vim...@googlegroups.com
yes. The first time I used "set noautoindent" but found not much useful.
Then I searched and found "set paste" which did work fine.
How to setup it by global? thanks.

on 2019/8/27 14:49, wsd...@163.com wrote:
> you can use set paste

Tony Mechelynck

unread,
Aug 27, 2019, 5:12:15 AM8/27/19
to vim_use
On Tue, Aug 27, 2019 at 10:54 AM Eliza <e...@chinabuckets.com> wrote:
>
> yes. The first time I used "set noautoindent" but found not much useful.
> Then I searched and found "set paste" which did work fine.
> How to setup it by global? thanks.

You shouldn't set it permanently, because it has a lot of
side-effects: it sets a lot of options to off or to 0, and in
addition, in 'paste' mode, mappings don't work.

What you can do is ":set paste" just before pasting and ":set nopaste"
afterwards. Or use a 'pastetoggle' as explained in the help.

Best regards,
Tony.

Eliza

unread,
Aug 27, 2019, 5:23:19 AM8/27/19
to vim...@googlegroups.com
Hi

on 2019/8/27 17:11, Tony Mechelynck wrote:
> You shouldn't set it permanently, because it has a lot of
> side-effects: it sets a lot of options to off or to 0, and in
> addition, in 'paste' mode, mappings don't work.
>
> What you can do is ":set paste" just before pasting and ":set nopaste"
> afterwards. Or use a 'pastetoggle' as explained in the help.

that's right. thanks.

Paul

unread,
Aug 31, 2019, 11:55:39 AM8/31/19
to vim_use
On Tue, Aug 27, 2019 at 11:11:56AM +0200, Tony Mechelynck wrote:
>What you can do is ":set paste" just before pasting and ":set nopaste"
>afterwards. Or use a 'pastetoggle' as explained in the help.

Another option is to make use of bracketed paste, if possible: https://cirw.in/blog/bracketed-paste
signature.asc
Reply all
Reply to author
Forward
0 new messages