Bug#868252: vim-nox: pressing <CR> on last line of a foldmethod=manual behaves differently at end of file

James McCoy jamessan at debian.org
Mon Oct 9 12:14:10 UTC 2017


On Thu, Jul 13, 2017 at 07:14:03PM +0000, Daniel Shahaf wrote:
> I use foldmethod=manual.  When I want to add a line following the last
> line of a fold, I use «A<CR>» if I want the line new to be included in
> the fold, and «o» if I want the new line not to be included in the fold.
> 
> However, I find that «A<CR>» behaves differently in the following two
> cases:
> 
> 1. The current line is the last line of a fold and of the file
> 
> 2. The current line is the last line of a fold but not the last line of the file
> 
> In case #2, «A<CR>» and «o» behave as I described above.
> 
> In case #1, «A<CR>» adds a new line to the file but doesn't make it part
> of the fold, i.e., it behaves as «o» does.
> 
> I expected «A<CR>» in case #1 to add a new line to the file *and to make
> it part of the fold*, as it does in case #2.
> 
> Case #1 (the problem case) is:
> 
>     % vim.nox -Nu NONE -c 'set fdc=2' -c 'normal! zf0' -c 'execute "normal! A\<CR>"'
> 
> Case #2 (the role model / reference case) is:
> 
>     % vim.nox  -Nu NONE -c 'set fdc=2' -c 'normal! 2o' -c 'normal! ggzfjzRggj' -c 'execute "normal! A\<CR>"'

A better example here is to use "zf0" instead of "zfj" so the same type
of fold is created.  This emphasizes that the problem is due to the fold
in the first example being at EOF, rather than it being a difference
between 1-line fold and >1-line fold.

> To be clear, the incumbent behaviour — adding a line to the file but not
> to the fold — should continue to be available under the «o» normal mode
> command, for the same reason: consistency with the not-end-of-file case.

Agreed.  I'll raise the issue upstream.

Cheers,
-- 
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7  2D23 DFE6 91AE 331B A3DB



More information about the pkg-vim-maintainers mailing list