19
當我複製一個Python代碼,並粘貼到vim。縮進都是錯誤的。 但我粘貼到emacs或gedit,它是正確的。如何將源代碼粘貼到vim而沒有錯誤格式?
這是很難描述,讓我們看看截圖。 注意:藍色和黃色線只是使用「縮進指南插件」。
這是源代碼示例:
import threading
import time
class timer(threading.Thread): #The timer class is derived from the class threading.Thread
def __init__(self, num, interval):
threading.Thread.__init__(self)
self.thread_num = num
self.interval = interval
self.thread_stop = False
def run(self): #Overwrite run() method, put what you want the thread do here
while not self.thread_stop:
print 'Thread Object(%d), Time:%s/n' %(self.thread_num, time.ctime())
time.sleep(self.interval)
def stop(self):
self.thread_stop = True
def test():
thread1 = timer(1, 1)
thread2 = timer(2, 2)
thread1.start()
thread2.start()
time.sleep(10)
thread1.stop()
thread2.stop()
return
if __name__ == '__main__':
test()
非常感謝你。如果我打開粘貼模式,是否對其他東西有任何影響,例如編輯代碼等? – 2012-03-23 01:51:12
它只是禁用所有與輸入文本格式相關的設置。見':help paste' – 2012-03-23 09:31:33