How to remove the fold level numbers in vim?

1.2k Views Asked by At

I'm using NeoVIM, and I set up it to show folds automatically. The trouble is that when there is more than one level of folds, it's going to show numbers at the left. enter image description here

Is there any way to remove them, just look like any other modern editors?

I searched on google, StackOverflow, and checked the vimhelp page. I haven't seen a way for this.

I'm sure that's the default behavior, I can reproduce it on the default vim of codesandbox and without any plugin. Please check this link https://codesandbox.io/s/wizardly-tereshkova-vwh5im?file=/README.md. Here is the screenshot.

enter image description here

3

There are 3 best solutions below

0
On

As explained in :help fold-foldcolumn, when the value of :help 'foldcolumn is large enough, the fold level is indicated by vertical bars but, when there is not enough room, numbers are used instead. That behavior is not governed by any option so there is nothing you can do about it except rolling up your sleeves and modifying the source code.

That said, the ˇs in your screenshot are clearly not standard `:help 'fillchars', as hinted in the comments, so you should probably take a look at what is redefining those before taking any action.

0
On

put these in your rc file.

vimscript:

set foldcolumn 0

lua

vim.opt.foldcolumn = '0'

if it still doesn't work, then verify the value is 0 by :set foldcolumn. If it is not 0, it might be because you are overriding the value in your config somewhere.

HINT:

some plugins suggest setting the value to 1, thus if you copied their suggested config, the issue might be there.

Edit: this will also make them unclickable, so might not work for you.

0
On

If someone still looks for an asnwer, this configuration in luukvbaal/statuscol.nvim solves the issue. I tested it myself.

  {
    'luukvbaal/statuscol.nvim',
    opts = function()
      local builtin = require('statuscol.builtin')
      return {
        setopt = true,
        -- override the default list of segments with:
        -- number-less fold indicator, then signs, then line number & separator
        segments = {
          { text = { builtin.foldfunc }, click = 'v:lua.ScFa' },
          { text = { '%s' }, click = 'v:lua.ScSa' },
          {
            text = { builtin.lnumfunc, ' ' },
            condition = { true, builtin.not_empty },
            click = 'v:lua.ScLa',
          },
        },
      }
    end,
  }