Link to home
Start Free TrialLog in
Avatar of enthuguy
enthuguyFlag for Australia

asked on

set paste on my session in Linux

Hi Linux Experts,

Currently, when I paste yaml or jason (or any text) in vi editor. It is not aligning well. So every time I have to ": set paste"

Is there a way I can set this on my session pls?

how to set to my current session
how to set this in bash_profile

please advice
Avatar of noci
noci

Either invoke vim with :
vim --cmd 'set paste'
or
create a ~/.vimrc file containing
set paste

Open in new window

And other optional commands
You can set the environment variable EXINIT to do this. Put the following line in your ~/.bashrc, ~/.bash_profile, ~/.profile or wherever
export EXINIT='set paste'

Open in new window

In my .bashrc I have export EXINIT='se showmode number ai' - you might like to include some of these also
No I meant EXINIT. I tried unsetting EXINIT and line numbers in vim stopped.
And when I tried export EXINIT='se showmode number ai paste' I see -- INSERT (paste) -- in the status line. (and ai starts turned off as per vim help)
@noci please post how you came to the conclusion that "EXINIT doesn't work for 'set paste'"
(I tested with the o command)
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Interesting - thanks for getting to the bottom of that. Possibly a bug (that EXINIT only works w/out ~/.vimrc); but VIMINIT is clearly the better way to go.
So ... the OP could put
export VIMINIT='set paste'

Open in new window

in ~/.bashrc, ~/.bash_profile, ~/.profile or wherever
Avatar of enthuguy

ASKER

Thanks a lot noci and Duncan, that VIMINT did the trick for me.