简体   繁体   English

为什么使用 vi 编辑器打开时行折叠 Linux

[英]Why are lines collapsed when opened using vi editor Linux

When i open any file for editing the lines are collapsed as you can see below:当我打开任何文件进行编辑时,这些行都会折叠起来,如下所示:

$ vi va_action.yml
  1 ---
  2
  3 - name: "Play 1 - Set Destination details"
  4 +-- 35 lines: hosts: localhost-----------------------------------------------------------------------------
 39
 40
 41
 42 - name: "Play 1.5 Validate files and folder on Destination nodes {{ dest_nodes }} with user {{ ansible_user     }}"
 43 +

I have to keep expanding the + tree to view entire file.我必须不断扩展+树才能查看整个文件。

I want the vi editor to simple not collapse anything.我希望 vi 编辑器简单而不折叠任何东西。 All the lines should be visible in the vi editor.所有行都应该在vi编辑器中可见。

$ vi -version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 30 2020 08:08:00)
Garbage after option argument: "-version"
More info with: "vim -h"

$ uname -a
Linux myhost 3.10.0-1160.25.1.el7.x86_64 #1 SMP Tue Apr 13 18:55:45 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux

You can try to put following line in ~/.vimrc:你可以尝试在 ~/.vimrc 中加入以下行:

se foldmethod=manual

First, you are using Vim, not vi, which didn't have folding.首先,您使用的是 Vim,而不是没有折叠功能的 vi。

Second, that behaviour is not standard so either you set Vim up that way or someone else did it on your behalf:其次,这种行为不是标准的,所以要么以这种方式设置 Vim,要么其他人代表这样做:

Some possible reasons…一些可能的原因……

  • You have this in your vimrc :你的vimrc中有这个:

     set foldlevel=0

    You can remove it to prevent folds from being closed automatically or you can adjust the value to your liking.您可以删除它以防止折叠自动关闭,或者您可以根据自己的喜好调整该值。

  • You did something like zM , which closes every fold, and then saved a view or session, automatically or manually, so every time you will open that file, the saved view will be restored, with all folds closed.你做了类似zM的事情,它关闭了每一个折叠,然后自动或手动保存了一个视图或 session,所以每次你打开该文件时,保存的视图将被恢复,所有折叠都关闭。

    Deleting that view or session should make those closed folds disappear.删除该视图或 session 应该会使那些关闭的折叠消失。

In any case, :help folding will be a very informative read.无论如何, :help folding将是一本非常有用的读物。

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

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