为什么当我将文本从浏览器复制并粘贴到文件时,Vim会再次缩进每一行?
为什么当我将一些文本从浏览器窗口复制到用Vim编辑的文件中时会出现这种情况?如何使线路正确排列为什么当我将文本从浏览器复制并粘贴到文件时,Vim会再次缩进每一行?,vim,Vim,为什么当我将一些文本从浏览器窗口复制到用Vim编辑的文件中时会出现这种情况?如何使线路正确排列 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
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
您可能启用了
autoindent
或cindent
。当您打开其中一个选项时,Vim不知道粘贴到终端中的新行与您自己输入的新行之间的区别。因此,当你粘贴一个换行符时,Vim会缩进该行,然后你还会粘贴空白,提供一个额外的缩进,以此类推,直到你在屏幕上比你想要的更远
解决方法是使用:set paste
设置粘贴模式,然后使用粘贴,然后使用:set nopaste
关闭粘贴模式。在粘贴模式下,Vim不会自动缩进行,因此将大量行粘贴到终端不会导致不断增加的缩进
如果您的特定平台上支持带剪贴板的Vim,您还可以使用
“*
和”+
寄存器进行粘贴(例如,使用“*p
进行粘贴),这也不会有这个问题。实现相同结果的另一种方法的可能重复::设置noai
禁用自动缩进
模式,:设置ai
再次启用