开发者

make vim recognize dollar sign as start of sentence

开发者 https://www.devze.com 2023-02-14 18:47 出处:网络
Suppose I have something written in latex like this: \\begin{problem} [37] \\end{problem} \\begin{solution}

Suppose I have something written in latex like this:

\begin{problem}
    [37]
\end{problem}
\begin{solution}
  $A$ is not equal to $B$. $C$ is not equal to $D$. 
\e开发者_运维百科nd{solution}

If I have my cursor in the 2nd sentence, "das" will act as I expect it to. But if I have my cursor in the 1st sentence, "das" will delete everything before "$C$ is not equal to $D$.", including the first 4 lines ("\begin{problem} to \begin{solution}). How can I make vim not delete the first 4 lines? Thanks!


I don't believe that you can change this. Vim is seeing <whitespace>$A$ is not equal to $B$.<whitespace> as the sentence. If you use dis instead it will preserve the space between the sentences but I am assuming that you want it to preserve the space before the sentence.

I was curious, so I looked it up in the documentation for "das":

"das" delete a sentence das

A sentence is defined as:

A sentence is defined as ending at a '.', '!' or '?' followed by either the end of a line, or by a space or tab. Any number of closing ')', ']', '"'' and ''' characters may appear after the '.', '!' or '?' before the spaces, tabs or end of line. A paragraph and section boundary is also a sentence boundary.

If the 'J' flag is present in 'cpoptions', at least two spaces have to follow the punctuation mark; s are not recognized as white space. The definition of a sentence cannot be changed.

The last line is what is important: The definition of a sentence cannot be changed. This is a bit surprising given the general flexibility of vim, but I guess that there are limits around if you look hard enough.


One way to do is just to add a newline after \begin{solution}.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号