2

I am using zc to collapse and zo to expand the code in vim. My problem is that when I walk through the code using j and k. code that is collapsed is got expand. I want to walk through collapsed code. what can I do?

I am using vim in VScode. But the same is true if I use vim in the terminal.

  • 1
    This is strange since this doesn't happen to me when I run vim in the terminal - although using `h` and `l` does expand a fold (I assume that's intended behaviour though). Could you add your vim version and be sure to include any settings from your .vimrc that relate to vim's folding behaviour – mattb Jun 26 '21 at 16:36
  • I have been using `vim` and `gvim` for more than 10 years and I agree with what mattb says: expending folds after `j` and `k` is strange and unusual side-effect. – Doj Jun 27 '21 at 09:03
  • What does `:set foldclose?` shows in your vim? – dlmeetei Jun 28 '21 at 08:58
  • @dlmeetei `:set foldclose?` give output `foldclose=` then I write `:set foldclose=all` now it's working fine thanks. – Shriman Keshri Jul 01 '21 at 05:13
  • For VScode I get the solution [here](https://stackoverflow.com/questions/50888475/code-folds-are-automatically-opened-when-cursor-moves-over-them-in-vs-code-vim). – Shriman Keshri Jul 01 '21 at 05:16

0 Answers0