简体   繁体   English

浏览文件时Vim崩溃

[英]Vim crashing when navigating through file

I'm very very new to Vim. 我对Vim非常陌生。 I've been using it for 2 days now (out of the womb new), and I've been having some problems navigating a certain Ruby file of mine without it crashing. 我已经使用了2天了(在新的子宫内),并且在浏览我的某个Ruby文件而没有崩溃时遇到了一些问题。

Before I get to the error message, here are the steps I did to reproduce the problem... 在得到错误消息之前,这是我重现问题的步骤...

  1. First I opened up the file as read-only with the :edit command 首先,我使用:edit命令将文件打开为只读文件

  2. If the file has no syntax coloring turn it on :syntax on . 如果文件没有语法着色,则将其打开:syntax on (For some reason it doesn't crash without it.) (由于某种原因,没有它就不会崩溃。)

  3. Navigate up and down the file with j and k (reproduces the crash quicker when you set the cursor in a position where it would scatter the cursor more. For ex, the end of a line) 使用jk上下浏览文件(将光标置于会更分散光标的位置时,可以更快地重现崩溃,例如,一行的结尾)


At first I thought something was wrong with my .rb file, but I was able to reproduce the same crash with the tk.rb file as well which is located in lib\\ruby\\2.2.0\\ folder. 起初我以为.rb文件出了点​​问题,但是我也能够使用位于lib\\ruby\\2.2.0\\文件夹中的tk.rb文件重现同样的崩溃。 It took some more time to do it with tk.rb since the comments in the code make it harder to crash. 使用tk.rb花费了更多时间,因为代码中的注释使崩溃更加困难。 (I recommend to try it on files with lots of lines like this). (我建议在具有很多这样的行的文件上尝试使用它)。

Here's a gif of me reproducing the problem and the file I was navigating through to reproduce the crash... 这是我重现问题的图像和正在导航以重现崩溃的文件...

http://puu.sh/jHXXG/14d2cf6460.gif http://puu.sh/jHXXG/14d2cf6460.gif

http://puu.sh/jHVG2/fdae9e38fa.rar http://puu.sh/jHVG2/fdae9e38fa.rar

I'm using Vim 7.4 and windows 10. If any more information is needed please ask in the comments. 我正在使用Vim 7.4和Windows10。如果需要更多信息,请在评论中询问。 I would like to know how to resolve this. 我想知道如何解决这个问题。 Vim looks like a really nice program. Vim看起来像是一个非常不错的程序。 However, if its gonna break itself and my heart from navigating with hjkl . 但是,如果它会因hjkl导航hjkl自己和我的心碎。 I might have to travel back to the fork in the road, and walk down the emacs path. 我可能不得不回到公路的前叉,然后沿着emacs的路径走。

As it was indicated on the comments, you should open a bug report if the problem is indeed in Vim. 正如评论中指出的那样,如果问题确实存在于Vim中,则应打开一个错误报告。

But first you should try the following: 但首先,您应该尝试以下操作:

  1. Ensure you are using a version with the latest patches; 确保您使用的是带有最新补丁程序的版本; there were some reports similar to the problem you are describing, and there are chances that it is already solved. 有一些报告与您描述的问题类似,并且有可能已经解决。
  2. Check if any setting/plugin is triggering the problem, beyond the :syntax . 除了:syntax之外,检查是否有任何设置/插件正在触发问题。 The procedure at Vim-FAQ 2.5 can be helpful. Vim-FAQ 2.5中的过程可能会有所帮助。 Some relevant parts follows: 一些相关的部分如下:

2.5. 2.5。 I have a "xyz" (some) problem with Vim. 我在Vim中遇到“ xyz”(某些)问题。 How do I determine it is a problem with my setup or with Vim? 如何确定我的安装程序或Vim存在问题? / Have I found a bug in Vim? /我是否在Vim中发现错误?

First, you need to find out, whether the error is in the actual runtime files or any plugin that is distributed with Vim or whether it is a simple side effect of any configuration option from your .vimrc or .gvimrc. 首先,您需要找出错误是在实际的运行时文件中还是在与Vim一起分发的任何插件中发生,或者这是来自.vimrc或.gvimrc中任何配置选项的简单副作用。 So first, start vim like this: 所以首先,像这样启动vim:

 vim -u NONE -U NONE -N -i NONE 

this starts Vim in nocompatible mode (-N), without reading your viminfo file (-i NONE), without reading any configuration file (-u NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc file) or even plugin. 这将以不兼容模式(-N)启动Vim,而不读取viminfo文件(-i NONE),不读取任何配置文件(-u NONE表示不读取.vimrc文件,-U NONE表示不读取.gvimrc文件),或者甚至插件。

If the error does not occur when starting Vim this way, then the problem is either related to some plugin of yours or some setting in one of your local setup files. 如果以此方式启动Vim时未发生错误,则说明问题与您的某些插件或本地设置文件之一中的某些设置有关。 You need to find out, what triggers the error, you try starting Vim this way: 您需要找出引发错误的原因,然后尝试通过以下方式启动Vim:

 vim -u NONE -U NONE -N 

If the error occurs, the problem is your .viminfo file. 如果发生错误,则问题是您的.viminfo文件。 Simply delete the viminfo file then. 只需删除viminfo文件即可。 If the error does not occur, try: 如果没有发生错误,请尝试:

 vim -u ~/.vimrc --noplugin -N -i NONE 

This will simply use your .vimrc as configuration file, but not load any plugins. 这将仅使用您的.vimrc作为配置文件,但不会加载任何插件。 If the error occurs this time, the error is possibly caused by some configuration option inside your .vimrc file. 如果这次发生错误,则该错误可能是由.vimrc文件中的某些配置选项引起的。 Depending on the length of your vimrc file, it can be quite hard to trace the origin within that file. 根据vimrc文件的长度,很难在该文件中跟踪源。

The best way is to add :finish command in the middle of your .vimrc. 最好的方法是在.vimrc的中间添加:finish命令。 Then restart again using the same command line. 然后使用相同的命令行再次重新启动。 If the error still occurs, the bug must be caused because of a setting in the first half of your .vimrc. 如果错误仍然存​​在,则该错误必须是由于.vimrc的前半部分中的设置引起的。 If it doesn't happen, the problematic setting must be in the second half of your .vimrc. 如果没有发生,那么有问题的设置必须位于.vimrc的后半部分。 So move the :finish command to the middle of that half, of which you know that triggers the error and move your way along, until you find the problematic option. 因此,将:finish命令移至该一半的中间,您会知道这会触发错误并继续前进,直到找到有问题的选项。 If your .vimrc is 350 lines long, you need at a maximum 9 tries to find the offending line (in practise, this can often be further reduced, since often lines depend on each other). 如果您的.vimrc长为350行,则最多需要9次尝试找到有问题的行(实际上,由于行之间相互依赖,通常可以进一步减少该行)。

If the problem does not occur, when only loading your .vimrc file, the error must be caused by a plugin or another runtime file (indent autoload or syntax script). 如果没有发生此问题,则仅在加载.vimrc文件时,该错误必须是由插件或另一个运行时文件(缩进自动加载或语法脚本)引起的。 Check the output of the :scriptnames command to see what files have been loaded and for each one try to disable each one by one and see which one triggers the bug. 检查:scriptnames命令的输出,以查看已加载了哪些文件,并尝试逐个禁用每个文件,并查看哪个文件触发了该错误。 Often files that are loaded by vim, have a simple configuration variable to disable them, but you need to check inside each file separately. 通常,vim加载的文件都有一个简单的配置变量来禁用它们,但是您需要分别检查每个文件的内部。

  1. If the previous steps doesn't solved the problem you could try checking similar bug reports and try maybe some of the patches which still weren't merged: 如果前面的步骤不能解决问题,您可以尝试检查类似的错误报告,并尝试一些尚未合并的补丁:

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

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