简体   繁体   中英

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. All the lines should be visible in the vi editor.

$ 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:

se foldmethod=manual

First, you are using Vim, not vi, which didn't have folding.

Second, that behaviour is not standard so either you set Vim up that way or someone else did it on your behalf:

Some possible reasons…

  • You have this in your 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.

    Deleting that view or session should make those closed folds disappear.

In any case, :help folding will be a very informative read.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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