打开vim抛出错误“尾随字符”[已关闭]

4nkexdtk  于 2022-11-11  发布在  其他
关注(0)|答案(2)|浏览(145)

**已关闭。**此问题为not reproducible or was caused by typos。目前不接受答案。

这个问题是由一个打字错误或一个无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
7个月前关闭。
Improve this question
我的配置文件很小。下面是我的完整.vimrc


# Enable mouse

set mouse=a

" Enable syntax highlighting
syntax on

# Add numbers on the left side

set number

打开Vim会抛出错误“尾随字符”。
每次我试图打开Vim,这些错误就出现了。我不明白这些错误。那么我在这里做错了什么呢?
错误如下:
截图:

正文:

dana@sunyata ~ % vim .vimrc
Error detected while processing /Users/dana/.vimrc:
line    1:
E488: Trailing characters: Enable mouse: # Enable mouse
line    7:
E488: Trailing characters: Add numbers on the left side: # Add numbers on the left side
line   10:
E488: Trailing characters: Ability to copy from Vim to other software: # Ability to copy from Vim to other software
Press ENTER or type command to continue

“尾随字符”是什么意思?如何修复这些错误?

whitzsjs

whitzsjs1#

  1. virmc中的每一行都是一个Ex命令。
  2. :#是一个Ex命令,它打印行,因此不能用于注解。Vim抱怨“尾随字符”,因为您给予它错误的命令,如:
:# Enable mouse

这些文件包含太多垃圾信息,因此无法正确解析。

  1. Vim使用"作为注解。
    1.如果您还没有,请根据需要多次执行$ vimtutor,以获得正确的基础知识。
    1.按照Vimtutor最后的指导,升级到用户手册:help user-manual。这是一个实践教程,将引导你逐步通过 * 每一个 * 功能,从基础到高级。这不是一个小说,按照你自己的节奏去做,最重要的是,沿着路实验。
    1.注意反模式和低效的行为,找出改进之处,练习,冲洗,重复。
b4lqfgs4

b4lqfgs42#

我不得不在.vimrc配置文件中将注解字符从#更改为"

以下是比较:

带有尾随字符错误的旧版本:


# Enable mouse

set mouse=a

" Enable syntax highlighting
syntax on

# Add numbers on the left side

set number

修正版本,无错误:

" Enable mouse
set mouse=a

" Enable syntax highlighting
syntax on

" Add numbers on the left side
set number

相关问题