2

Although I have no problem using SecureCRT (5.1.2 build 274) to work from Windows and connect to PC's running Linux, I have a problem when connecting to an embedded Asterisk appliance that provides"vi" through BusyBox 1.4.1 (2008-03-10).

The issue I'm having, is that when I paste code into vi, the text appears jagged like this:

<?php                                                                                                                               
try {                                                                                                                               
        $dbh = new PDO("sqlite:./db.sqlite");                                                                                       
                $dbh->exec("CREATE TABLE IF NOT EXISTS customer (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255))");        

Does someone what the problem is? Is there a way to reconfigure either BusyBox or SecureCRT so that I can paste successfully?

Thank you.

Gulbahar
  • 5,343
  • 20
  • 70
  • 93

2 Answers2

4

This is vi's auto-indent conflicting with the existing indentation. Activate paste mode before pasting.

<ESC>:set paste

NB: I usually use vim. It is possible that the feature doesn't exist in vi.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I'm guessing when he said `vi` he actually meant `vim`. I cant think of any reason why people still using `vi` when backwards-compatible, superior and awesome `vim` is around. – Jeffrey Jose Jun 10 '10 at 18:48
  • He also mentioned BusyBox, which suggests an extremely limited (in RAM and CPU) environment (such as a consumer grade router). – Quentin Jun 10 '10 at 19:02
  • Thanks for the tip, but ":set paste" doesn't work on this minimal vi as part of BusyBox :-/ I'll see if I can recompile a newer version to solve this issue. – Gulbahar Jun 18 '10 at 07:56
1

I'd guess you have smartindent or autoindent turned on. I used to do set si! and set ai!, but David Dorward's answer seems to have the same effect. (I'll have to remember that one. :) )

I think set ai is the only one in vanilla vi. If you want to force it to turn off, do set noai (set ai! just flips the state.)

Benjamin Oakes
  • 12,262
  • 12
  • 65
  • 83