1

This post is not about curly brackets. It is about parentheses.

I couldn't find a solution on how to expand parentheses with my ideal indentation.

What happens now with expanding parentheses

Before

(|)

Input

<CR>

After

(
    |
    )

What I want

Before

(|)

Input

<CR>

After

(
    |
)

I have delimitMate installed, but I don't think this is delimitMate's problem because it produces the same output without delimitMate. Yes, I experimented it.

The closest I've gotten was with filetype indent off, which successfully aligns the closing parenthesis with the opening one. However, the cursor's position ends up where I don't want it to be.

What happens with the filetype option and delimitMate

Before

(|)

Input

<CR>

After

(
|
)

What heppens with the filetype option and without delimitMate

Before

(|)

Input

<CR>

After

 (
|)

Ideally, I want a solution with delimitMate installed, but I think a solution without delimitMate will be a good foundation to solve this with delimitMate. So, I want to hear any solution to this with or without delimitMate.

3
  • Note that this depends on your filetype (for example it happens with Python, but not vim) -- and also happen with v_= (although it can be inconsistent). Try set indentexpr= and/or set cindent cino=m1
    – user202729
    Sep 21 at 8:31
  • That didn't do anything.
    – tet
    Sep 21 at 10:45
  • Also check smartindent, autoindent, etc., and decide if those are set to the correct values. Frankly this type of thing is an issue in most "auto delimiter" style plugins—it's probably a corner case. The plugin authors might be able to help. Otherwise, you might want to make a mapping that does what you want
    – D. Ben Knoble
    Sep 22 at 19:56
1

I kind of solved the problem.(There might be a better way.)

Here is what I did as a Rust programmer.

  1. I installed rust.vim plugin.
  2. I found a pending pull request for the plugin.
  3. I added the code manually from that pull request to see how it works.

It gave me the indentation.

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.