0

with autoindent mode on, when writing a short bullet point on restructuredtext file:

- item one
         ~

Then I press Enter, and I get:

- item one
  ~

but I whould like to quickly by here:

- item one
- 
  ~

so ready to fill my - item two

right now I have to do ESC[enter]i[space][space] before to be ready to write my item two.

After adding the @Ralf vars:

:setlocal comments+=b:-
:setlocal formatoptions+=ro

Here the check of vars values:

:set formatoptions?
     formatoptions=tcqlro
:set comments?
     comments=fb:..,b:-
:print
     - toto

In insert mode, enter add the - but indented

- lkdsj
      ~         <= press Enter
  - qsdfqsdf
           ~    <= press Enter
    - lqkfdjqd
             ~  <= press Enter
      - toto

In normal mode o add the - but indented:

- lkdsj
      ~         <= press o
  -
    ~           # in insert mode but indented

In normal mode O add the - not indented but line above:

- ~             <= 2. item added above
- lkdsj
      ~         <= 1. press O
2

This works with the options formatoptions and comments.

Create the file .vim/after/ftplugin/rst.vim and add the following lines:

setlocal comments+=b:-
setlocal formatoptions+=ro

For comments, the b:- adds the the dash as a comment character that has to be followed by a blank. See :help 'comments' and :help format-comments

For formatoptions, the r inserts the comment leader when hitting Enter. The o inserts the comment leader on hitting o or O in normal mode. See :help 'formatoptions' and :help fo-table.

  • thank you, when I hit O it add a new line above when I it o it add a line below but ... indented – user3313834 Oct 11 at 17:48
  • @user3313834 What does set formatoptions? print? And set comments? ? – Ralf Oct 12 at 0:52

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.