From e986c07710e2ae9c685d65584a2746318a5c01f7 Mon Sep 17 00:00:00 2001 From: somini Date: Wed, 11 Sep 2019 18:20:25 +0100 Subject: [PATCH 1/2] Ignore the border lines on `iz` This will ignore the first and last fold lines on `iz` motion. Only useful on `foldmethod=marker`, so ignore this on other methods. Cherry-picked from c459711504408fa15bf1b404f47e055fb2ac8837 --- autoload/textobj/fold.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/autoload/textobj/fold.vim b/autoload/textobj/fold.vim index 3cff484..ab46ae1 100644 --- a/autoload/textobj/fold.vim +++ b/autoload/textobj/fold.vim @@ -39,12 +39,20 @@ endfunction function! textobj#fold#select_i() call s:move_to_the_start_point() let start_pos = getpos('.') + if &foldmethod ==# 'marker' + " Next line + let start_pos[1] += 1 + endif for i in range(v:count1 - 1) call s:move_to_the_end_point('i', 0) normal! j endfor call s:move_to_the_end_point('i', 0) let end_pos = getpos('.') + if &foldmethod ==# 'marker' + " Previous line + let end_pos[1] -= 1 + endif return ['V', start_pos, end_pos] endfunction From 4bffa97acdd9c7f6b229d889b4d1cb4790fa4790 Mon Sep 17 00:00:00 2001 From: somini Date: Wed, 11 Sep 2019 18:20:49 +0100 Subject: [PATCH 2/2] Note the new behaviour in the documentation. Cherry-picked from a261c8094cfbee9bfa23cdbdc73123dba62a0334 --- doc/textobj-fold.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/textobj-fold.txt b/doc/textobj-fold.txt index 86e5cbb..9489976 100644 --- a/doc/textobj-fold.txt +++ b/doc/textobj-fold.txt @@ -72,6 +72,9 @@ KEY MAPPINGS *textobj-fold-key-mappings* Leading or trailing lines which are not in any foldings are also counted too. + If the current |foldmethod| is "foldmarker", ignore the lines that + contain the marker. + Note that this object is linewise. In Visual mode, the current selection will be switched to linewise. In Operator-pending mode, affected text will be linewise. @@ -105,9 +108,6 @@ BUGS *textobj-fold-bugs* - Even if user explicitly specify a wise for an operator by |o_v| or others, |(textobj-fold-a)| and |(textobj-fold-i)| are always linewise. -- |(textobj-fold-a)| is not perfectly implemented. Currently, it - behaves as same as |(textobj-fold-i)|. - - In Visual-mode, the current selection is overriden by new selection. - In Visual-mode, repeating |(textobj-fold-a)| and other mappings don't