8

Paragraphs are delimited by empty lines, both in vim and tex, but sometimes I wish vim to treat an entity as a paragraph and not tex. Can I, e.g., make vim treat lines containing only a "%" as a paragraph delimiter?

  • 1
    See my answer to a similar question here: vi.stackexchange.com/a/6043/4932 also check out this plugin: github.com/vim-scripts/Improved-paragraph-motion – fruglemonkey Feb 15 '16 at 14:43
  • 1
    Plugin looks very interesting, but I got an error loading it: Error detected while processing /Users/lawrence/.vim/plugged/Improved-paragraph-motion/plugin/ipmotion.vim: line 50: E492: Not an editor command: ^M line 51: E15: Invalid expression: exists('g:loaded_ipmotion')^M line 145: E171: Missing :endif – Toothrot Feb 15 '16 at 15:00
  • 1
    @fruglemonkey, as far as I can understand the error was in the plugin. error messages went away after :set ff=unix. – Toothrot Feb 15 '16 at 16:12
  • 2
    The plugin affects only } and { motions, not text-objects. – Toothrot Feb 15 '16 at 16:26
  • 1
    Yeah, but you can otherwise create mappings that will let it behave 'like' a text object. Why do you want a custom paragraph delimiter? What action do you want to perform that would require one? – fruglemonkey Feb 15 '16 at 22:14
2

You cannot natively make % a pagraph delimiter, as paragraph macros are nroff macros (a dot, two characters: .xx)

However, you can add .%% (or any other combination you want) as a paragraph delimiter by adding it do the paragraphs option:

:set paragraphs=IPLPPPQPP\ TPHPLIPpLpItpplpipbp%%

See: :help paragraph:

A paragraph begins after each empty line, and also at each of a set of
paragraph macros, specified by the pairs of characters in the 'paragraphs'
option.  The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to
the macros ".IP", ".LP", etc.  (These are nroff macros, so the dot must be in
the first column).  A section boundary is also a paragraph boundary.
Note that a blank line (only containing white space) is NOT a paragraph
boundary.
Also note that this does not include a '{' or '}' in the first column.  When
the '{' flag is in 'cpoptions' then '{' in the first column is used as a
paragraph boundary posix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.