vim-markdown icon indicating copy to clipboard operation
vim-markdown copied to clipboard

How to unfold by default

Open glow12121 opened this issue 2 years ago • 7 comments

let g:vim_markdown_folding_level = 6
let g:vim_markdown_override_foldtext = 0

With the settings above, I cannot figure out how to keep everything in markdown texts unfolded by default.

Specifically, I don't see how to control lines and empty lines being folded. Probably let g:vim_markdown_override_foldtext = 0 has nothing to do with it.

## Title
+--  3 lines: ········································································································
### Title
+--  3 lines: Line of text···················································································

glow12121 avatar Feb 01 '23 20:02 glow12121

@glow12121 You may add something like this to your ~/.vimrc file:

autocmd FileType markdown normal zR

This commands run zR and unfold whole file on opening. Result might depends on position the line in ~/.vimrc file...

ilya-vv avatar Feb 03 '23 12:02 ilya-vv

Isn't it a workaround?

I cannot figure out why the plugin keeps on folding the text one way or another, whichever folding level I select. Even if it's, say, 6, still all the stuff is folded.

These are literally all my settings related to the plugin:

Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
" Syntax highlighting, matching rules and mappings for the original Markdown and extensions.
" The tabular plugin must come before vim-markdown.
" g:vim_markdown_folding_level setting (default 1) is set to foldlevel. Thus level 1 heading which is served as a document title is expanded by default.
" Folding level is a number between 1 and 6. By default, if not specified, it is set to 1.
let g:vim_markdown_folding_level = 0
" To prevent foldtext from being set add the following to your .vimrc:
" let g:vim_markdown_override_foldtext = 0

glow12121 avatar Feb 04 '23 10:02 glow12121

Well, yes. My suggestion is a workaround.

Can't say about vim-markdown - use it for several days - but, as I remember, when Vim receives command set foldmethod=..., it applies folding for the whole buffer and folds everything, it's default behavior.

ilya-vv avatar Feb 05 '23 00:02 ilya-vv

@glow12121,

I think the problem might be that foldlevel is a hacky way of opening folds. Maybe set foldlevelstart=6. This page might help!

mcookly avatar Feb 09 '23 02:02 mcookly

@mcookly Thanks for the tip setting that variable fixed the problem for me

Nan-Do avatar Mar 22 '23 04:03 Nan-Do

Thanks. This is working for me:

vim.cmd [[
    autocmd BufRead,BufNewFile *.markdown,*.md set conceallevel=2 foldlevelstart=6
]]

Don't know if there is a better way.

polirritmico avatar Jun 19 '23 01:06 polirritmico

I'm on lazy v10.15.1, based on this thread, I got it working with the following config:

{
  "preservim/vim-markdown",
  ft = "markdown",
  init = function()
    vim.cmd [[set foldlevelstart=6]]
  end,
  dependencies = {
    "godlygeek/tabular",
  },
}

vyrwu avatar Nov 20 '23 22:11 vyrwu