How to search for continuation line, as detected by c-indent in vim ? ie. the +N cinoption.

1 Answer 1


Vim's source code has a section dedicated to do this, and it's a lot more complicated than a simple regex. Here's a link to the neovim file that does this.

This leaves you with 2 options:

  1. Write your own regex to do a "close enough" guess job
  2. If you're using the +N option and can define continuation lines as lines that are indented N spaces more than the line before. You can use a regex to find these lines:

    \v^( +)\S.*\n\1    \zs\S
    \v                       "very magic mode" so we don't have to escape too many things
      ^                      start of a line
       ( +)                  all the spaces, captured in group 1
           \S                a non-space character
             .*              the rest of this line
               \n            newline
                 \1          the same number of spaces again
                       \zs   N extra spaces, then start the match
                          \S a non-space

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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