4

Not sure which stack exchange group this question goes so please move to the correct one if this is the wrong one.

What's happening is if I highlight something with tabs/indents from one window/browser and want to paste it into vi, the formatting gets 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 highlight it and paste it in 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 auto-indent is messing me up and to run

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

but this gets tiring after a while. Is there a workaround when pasting tabbed lines in vi with autoindent set to on or do I have to turn off auto-indent, paste, turn ai back on every time?

Thanks in advance for your help.

Classified
  • 5,759
  • 18
  • 68
  • 99
  • Sorry, not a programming question. Consider flagging your question to be moved to Superuser.com. Good luck. – shellter Jun 18 '13 at 21:37

1 Answers1

4

You have to use, in normal mode

:set paste

Then you paste what you want. To comeback to your original setting, use, in normal mode

:set nopaste
Luc M
  • 16,630
  • 26
  • 74
  • 89