lervag / lervag/vimtex

Add option to keep \[ ... \] on one line

Open
#3,300 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TeX
Stars
6.4k
Forks
416
Avg merge
1d 7h
Merged PRs (30d)
5

Description

Is your feature request related to a problem? Please describe it.
When I do the surround.vim bindings to change a math environment to \[, it automatically places the output on three lines. So for example, if we had a file (* is the cursor)

We can prove \( \pi >* \frac{22}{7} \) with calculus.

then hitting cse\[<C-r> converts this into

We can prove
\[
     \pi >* \frac{22}{7}
\]
with calculus.

whereas it's common to place these all on one line instead:

We can prove
\[ \pi >* 3 \]
with calculus.

Describe the solution you'd like
Ideally, some way of configuring the default behavior to match the second example

Describe alternatives you've considered
I could manually remove the newlines (mbkJJ`b to preserve cursor position in the line), but this loses me precious keystrokes, which are not always plentiful if I need to work very quickly.

Additional context
I know that for some people, the original behavior is their preferred behavior, which is why I think it should be configurable.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the surround.vim handling for converting ( ... ) to [ ... ], then inspect the existing configuration for math-environment formatting. The change is complete when users can choose the one-line form shown in the issue while the current multiline behavior remains available, with relevant behavior covered by the project's existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
tex, vim
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.