I have noticed that when I use :cn
:cp
directly, vim always expands folds for me. But when I set my custom mapping to call :cn
like :map <leader>n :cn<cr>
, vim doesn't expand foldings when I use <leader>n
in this case, I have to move horizontally after using that hotkey to unfold. I could script moving horizontally as well, but I still would like to understand why vim doesn't do that for me.
My foldopen
setting contains quickfix
.
Thanks.
According to this vim email archive.
This is the correct behavior and that you are supposed to open folds manually if you put :cn
or :cp
into mappings. The solution was to add zv
to the end of the mappings.
So your maps should look like this
noremap <leader>n :cn<CR>zv
Note: I change map to noremap because noremap stops recursive mappings whereas map allows for it.