简体   繁体   English

Vim - 奇怪的行为

[英]Vim - Weird Behaviour

I just recently deleted my .vimrc, and since I've added a few things back in and added some plugins I get this weird behaviour. 我刚刚删除了我的.vimrc,因为我已经添加了一些内容并添加了一些插件,我得到了这种奇怪的行为。

  1. I click 'i' to place me in insert mode. 我点击'i'将我置于插入模式。
  2. I type a character (any character) 我输入一个字符(任何字符)
  3. Suddenly I get a newline break right where I started typing. 突然间,我开始打字的地方就开始换线了。

Extremely annoying! 非常讨厌! :) Any ideas on what this might be? :)关于这可能是什么的任何想法?

Sanity check. 完整性检查。 What happens if you run as vim -C (compatibility mode, behave like plain vi ) or vim -u NONE (don't load any initialization files or plugins)? 如果你运行vim -C (兼容模式,行为像普通vi )或vim -u NONE (不加载任何初始化文件或插件)会发生什么?

No, but you could start taking things out of your .vimrc one at a time and see if the problem goes away. 不,但你可以一次开始从你的.vimrc中取出一些东西,看看问题是否消失了。 Whatever was last removed, may have been the culprit (not always because it could be conflicting plugins). 无论最后删除了什么,可能是罪魁祸首(并不总是因为它可能是相互矛盾的插件)。

There are quite a few things it could be given how customisable Vim is. 有很多东西可以给出可定制的Vim。 However I think it might be your setting of 'textwidth'. 但是我认为这可能是你对'textwidth'的设置。

From Vim Help: 从Vim帮助:

'textwidth' can be set to the maximum width for a line. 'textwidth'可以设置为一行的最大宽度。 When a line becomes too long when appending characters a line break is automatically inserted. 当附加字符时线条变得太长时会自动插入换行符。

So check what 'textwidth' is set to and either increase it, or set it to 0 to disable this feature. 因此,请检查'textwidth'设置为什么并将其增加,或将其设置为0以禁用此功能。

If this doesn't work, then try what everyone else said of just commenting out all your settings, checking this fixes the issue. 如果这不起作用,那么试试其他人说的只是评论你的所有设置,检查这个问题就可以解决问题。 Then slowly enabling settings again. 然后再次慢慢启用设置。 Maybe use a binary search :) 也许使用二进制搜索:)

You could back up your .vimrc file, remove the original and start up vim then create new vimrc: 您可以备份.vimrc文件,删除原始文件并启动vim然后创建新的vimrc:

:mkvimrc

Then you can start adding stuff from your old one and see which setting introduces the problem. 然后你可以开始添加旧的东西,看看哪个设置引入了问题。

Same with plugins, move all your (not system) plugins out of your plugins directory and add one by one and see which one introduces the problem. 与插件相同,将所有(非系统)插件移出插件目录并逐个添加,看看哪个插件引入了问题。

你的.vimrc一行一行注释,直到它按预期开始工作。

You could try using vim script debugging: "vim -D file". 您可以尝试使用vim脚本调试:“vim -D file”。 Then you could try to add some breakpoints, etc. 然后你可以尝试添加一些断点等。

Link: Debugging Vim Scripts 链接: 调试Vim脚本

这要求将.vimrc之类的文件设置为源代码控制。

You could post your vimfiles + vimrc somewhere so others can take a look at it, and maybe determine the source of an error. 您可以将vimfiles + vimrc发布到某个地方,以便其他人可以查看它,并可能确定错误的来源。

Saying that there is an error, without giving any concrete data, never resulted in anything. 如果没有提供任何具体数据,就会出现错误,从未产生任何结果。

Use some paste site, and post your vimrc, and a list of plugins (usually people use pretty much the same ones ... from www.vim.org). 使用一些粘贴网站,并发布你的vimrc和插件列表(通常人们使用几乎相同的...来自www.vim.org)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM