FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 01-27-2011, 07:11 PM
Petri Rosenström
 
Default Paste into vim keeping indention or original?

On Thu, Jan 27, 2011 at 9:28 PM, Mike Gilbert <floppymaster@gmail.com> wrote:
> On Thu, Jan 27, 2011 at 2:22 PM, Mark Knecht <markknecht@gmail.com> wrote:
>> I solved it by creating a .vimrc file and putting
>>
>> set pastetoggle=<F2>
>
> Running :set paste will do the job as well if you don't want to assign
> a hot key for it.
>
>

I usually do as Mike suggest. When I need to paste stuff into vim I
just type :set paste and paste the stuff and continue working.

Best regards
Petri
 
Old 01-27-2011, 07:53 PM
YoYo Siska
 
Default Paste into vim keeping indention or original?

On Thu, Jan 27, 2011 at 02:28:47PM -0500, Mike Gilbert wrote:
> On Thu, Jan 27, 2011 at 2:22 PM, Mark Knecht <markknecht@gmail.com> wrote:
> > I solved it by creating a .vimrc file and putting
> >
> > set pastetoggle=<F2>
>
> Running :set paste will do the job as well if you don't want to assign
> a hot key for it.

BTW, if
- vim has access to X (you run it on your local machine or from
ssh -X or something similar)
- is compiled with X support (check with vim --version | grep +X11)
- and you :set mouse=a
then you can paste by middle clicking in vim (not shift-middle click),
which should paste the text as is...

The difference is that with shift-middle click, or with vim that cannot
talk to X, the terminal sends the selected text to vim as normal input
(as if you would type it) and thus its get indented/formated/etc..

If you have mouse=a set and vim can talk to X, when you middle click
it will ask X for the selection and insert it as is without any
formatting

yoyo
 
Old 01-27-2011, 09:38 PM
James
 
Default Paste into vim keeping indention or original?

Mark Knecht <markknecht <at> gmail.com> writes:


> What is the solution to begin able to paste code I find on the web
> into a file in vim and being able to keep the indentation from
> changing?


Well, if you want to keep it simple, here is what I do:
edit /etc/vim/vimrc

"set ai " Always set auto-indenting on
set noai " No auto indenting (James added this



now pasting into with vi does not indent deeper with each line.

hth,
James
 

Thread Tools




All times are GMT. The time now is 06:34 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org