原子中片段的错误行为

时间:2017-03-02 20:17:50

标签: atom-editor code-snippets

我在atom中创建了以下片段:

'.plain.text':
    'cdot':
        'prefix': '\c'
        'body': '\cdot'
    'vec':
        'prefix': '\v'
        'body': '\vec{$1}$2'
    'equation':
        'prefix': '\e'
        'body': """
            \begin{equation}

            $1

            \end{equation}

            """

问题在于,当我调用它们时,第一个看起来是正确的,第二个看起来不正确,第三个看起来是:

\egin{equation}
end{equation}

为什么会这样?我该如何解决?

1 个答案:

答案 0 :(得分:1)

  • 从前缀中删除反斜杠\(或使用其他有效字符进行自定义)
  • 如果希望它们显示在\\\\上,请使用双重转义(body)。

段:

'.plain.text':
  'cdot':
    'prefix': 'c'
    'body': '\\\\cdot'
  'vec':
    'prefix': 'v'
    'body': '\\\\vec{$1}$2'
  'equation':
    'prefix': 'equation'
    'body': """
        \\\\begin{equation}

        $1

        \\\\end{equation}
    """

注意光标会根据需要显示,但会在图片中移动以显示代码段扩展名。

enter image description here enter image description here enter image description here