0

there,

I found that every-time when I copy piece of code from eclipse into vim, the format will totally be screwed up, and the indentation will be broken by adding lots of tabs in vim. Could someone has clues about how to keep the original program format when copying to vim?

JoJo
  • 1,377
  • 3
  • 14
  • 28

2 Answers2

2

Try enabling paste mode:

set paste
svlasov
  • 9,923
  • 2
  • 38
  • 39
0

You probably have a different set of tabstops in eclipse and in vim. Then when you have some tabs filled by spaces and others by tabs the spacing gets all messed up.

The default tabstop in vim is 8 spaces - either change that to whatever you use in eclipse or else change the eclipse tabstops to 8.

When I get started in a new environment the first thing I do in vim is this command:

:set ts=4 sw=4 et

That sets tabstops to 4, shiftwidth to 4, and expands tabs to spaces so that you don't have this problem if you open it with a different set of tabstops.

Peter Bowers
  • 3,063
  • 1
  • 10
  • 18