Reputation: 14270
Why do I get this when I copy some text from a browser window into a file I'm editing with Vim? How do I get the lines to line up properly?
from django.db import models
from django.contrib.gis.db import models
# Create your models here.
class WorldBorder(models.Model):
# Regular Django fields corresponding to the attributes in the
# world borders shapefile.
name = models.CharField(max_length=50)
area = models.IntegerField()
pop2005 = models.IntegerField('Population 2005')
fips = models.CharField('FIPS Code', max_length=2)
iso2 = models.CharField('2 Digit ISO', max_length=2)
iso3 = models.CharField('3 Digit ISO', max_length=3)
un = models.IntegerField('United Nations Code')
region = models.IntegerField('Region Code')
subregion = models.IntegerField('Sub-Region Code')
lon = models.FloatField()
lat = models.FloatField()
# GeoDjango-specific: a geometry field (MultiPolygonField)
mpoly = models.MultiPolygonField()
# Returns the string representation of the model.
def __str__(self): # __unicode__ on Python 2
return self.name
Upvotes: 4
Views: 7924
Reputation: 76489
You probably have either autoindent
or cindent
on. When you have one of those options on, Vim doesn't know the difference between the newlines that get pasted into the terminal and those you enter yourself. Therefore, when you paste a newline, Vim indents the line, and then you also paste whitespace providing an additional indent, and so on with the next line, until you're much farther over on the screen than you want.
The solution is to use :set paste
to set paste mode and then paste, then :set nopaste
to turn paste mode off. While in paste mode, Vim doesn't autoindent lines, so pasting a large number of lines into the terminal doesn't cause ever-increasing indents.
If you have a Vim with clipboard support on your particular platform, you can also paste using the "*
and "+
registers (e.g. with "*p
to paste), which won't have that problem, either.
Upvotes: 6