From ee626a75830ba2893946d02c52f9a9283528a009 Mon Sep 17 00:00:00 2001 From: Sebastian Koenig Date: Thu, 27 Aug 2020 15:14:34 -0400 Subject: [PATCH 1/3] Allow users to specify additional sentence terminators --- autoload/textobj/sentence.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/textobj/sentence.vim b/autoload/textobj/sentence.vim index f60bae6..8a73314 100644 --- a/autoload/textobj/sentence.vim +++ b/autoload/textobj/sentence.vim @@ -35,6 +35,8 @@ function! textobj#sentence#select_i() return s:select(b:textobj_sentence_re_i) endfunction +let g:re_extra_sentence_term = '' + function! textobj#sentence#init(...) let l:args = a:0 ? a:1 : {} @@ -87,7 +89,9 @@ function! textobj#sentence#init(...) " matching against end of sentence, '!', '?', and non-abbrev '.' let l:re_term = - \ '([!?]|(' . + \ '([!?]' . + \ g:re_extra_sentence_term . + \ '|(' . \ l:re_abbrev_neg_lookback . \ '\.))+[' . \ l:trailing . From b06897c03ef4228d993e1b13de974824c61fbb1d Mon Sep 17 00:00:00 2001 From: Sebastian Koenig Date: Thu, 27 Aug 2020 15:21:40 -0400 Subject: [PATCH 2/3] Updated documentation --- README.markdown | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 7b9cc48..3ceb4b7 100644 --- a/README.markdown +++ b/README.markdown @@ -115,6 +115,33 @@ key mappings via your `.vimrc`: let g:textobj#sentence#move_n = ')' ``` +### Additional custom sentence terminators + +Additional sentence terminators can be added by setting +`g:re_extra_sentence_term`. For example, the following will count +semicolons as sentence terminators: + +```vim +let g:re_extra_sentence_term = '|;' + +call textobj#sentence#init() +``` + +Note this variable is a regular expression, and evey entry needs to be +preceeded by `|`. + +The following can be used to count LaTeX environments as sentence +terminators, which is convenient for automatic rewrapping (e.g., via +`gqis`) that does not touch environments which are part of the sentence: + +```vim +let g:re_extra_sentence_term = + \ '|\\begin\{[a-zA-Z]*\}' . + \ '|\\end\{[a-zA-Z]*\}' + +call textobj#sentence#init() +``` + ## See also If you find this plugin useful, check out these others by [@reedes][re]: @@ -122,7 +149,7 @@ If you find this plugin useful, check out these others by [@reedes][re]: * [vim-colors-pencil][cp] - color scheme for Vim inspired by IA Writer * [vim-lexical][lx] - building on Vim’s spell-check and thesaurus/dictionary completion * [vim-litecorrect][lc] - lightweight auto-correction for Vim -* [vim-one][vo] - make use of Vim’s _+clientserver_ capabilities +* [vim-one][vo] - make use of Vim’s _+clientserver_ capabilities * [vim-pencil][pn] - rethinking Vim as a tool for writers * [vim-textobj-quote][qu] - extends Vim to support typographic (‘curly’) quotes * [vim-thematic][th] - modify Vim’s appearance to suit your task and environment @@ -146,7 +173,7 @@ If you find this plugin useful, check out these others by [@reedes][re]: If you’ve spotted a problem or have an idea on improving this plugin, please post it to the github project issue page. Pull requests that add -new regression tests (even failing ones that demonstrate a bug!) are +new regression tests (even failing ones that demonstrate a bug!) are welcome too. From c34cdbbea8bb3ccb3609c16dede6a08b919b7b88 Mon Sep 17 00:00:00 2001 From: Sebastian Koenig Date: Thu, 27 Aug 2020 16:23:51 -0400 Subject: [PATCH 3/3] Only set empty custom sentence terminators if not previously assigned --- autoload/textobj/sentence.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/textobj/sentence.vim b/autoload/textobj/sentence.vim index 8a73314..e93b439 100644 --- a/autoload/textobj/sentence.vim +++ b/autoload/textobj/sentence.vim @@ -35,7 +35,9 @@ function! textobj#sentence#select_i() return s:select(b:textobj_sentence_re_i) endfunction -let g:re_extra_sentence_term = '' +if !exists('g:re_extra_sentence_term') + let g:re_extra_sentence_term = '' +endif function! textobj#sentence#init(...) let l:args = a:0 ? a:1 : {}