How to cut and paste nested lines with automatic indentation set for inclusion in vi

If you don’t know which glass exchange group this issue is in, please go to the right one if this is not true.

What happens if I select something with tabs / indents from one window / browser and want to paste it into vi, the formatting becomes messed up.

For example, I have the following in another window that I want to copy:

"date_created" : "2013-06-06 21:12:31", "netdriver_duplex" : "Full", "mac_address" : "FA:16:3E:17:CC:E1", "interfaces" : "eth0,sit0", "processors" : null 

After I highlighted it and pasted into vi, I get the following:

  "date_created" : "2013-06-06 21:12:31", "netdriver_duplex" : "Full", "mac_address" : "FA:16:3E:17:CC:E1", "interfaces" : "eth0,sit0", "processors" : null 

Someone told me that auto-indentation confuses and starts me up

 ESC-> :set noai Copy/Paste stuff ESC-> :set ai 

but it is a little tiring. Is there a workaround when inserting nested lines in vi with autodetection turned on or do I need to disable auto-indent, insert, turn ai back on every time?

Thanks in advance for your help.

+4
source share
1 answer

You should use as usual

 :set paste 

Then you insert what you want. To return to the initial setting, use as usual

 :set nopaste 
+4
source

Source: https://habr.com/ru/post/1486933/


All Articles