Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacement string does not display backslash and the following letter #1495

Open
celdorwow opened this issue Oct 10, 2022 · 1 comment
Open

Comments

@celdorwow
Copy link

Expected behavior:
\begin{tabularx}{\linewidth}{cc}
X & X \\
\end{tabularx}

Actual behavior:
\begin{tabularx}{inewidth}{cc}
X & X \\
\end{tabularx}

Steps to reproduce

  1. Create a snippet
snippet tabu "Regular tabular" b
\\begin{tabular$1}${1/(\*)$|(x)$/(?1:{\\\linewidth})(?2:{\\\linewidth})/}{${2:cc}}
	$0X & X \\\\
\\end{tabular$1}
endsnippet
  1. Write tabu in a LaTeX file and press <TAB>
  2. The snippet displays \begin{tabular}{cc} and holds on position after r
  3. Appending * or x inserts {inewidth} in the middle but it should insert \linewidth.

As a comment, it doesn't matter how many times I escape \ in front of linewidth in the snippet

${1/(\*)$|(x)$/(?1:{\\linewidth})(?2:{\\linewidth})/}

or

${1/(\*)$|(x)$/(?1:{\\\linewidth})(?2:{\\\linewidth})/}

or

${1/(\*)$|(x)$/(?1:{\\\\linewidth})(?2:{\\\\linewidth})/}

the effect is the same.


  • Operating System: 20.04.5 LTS (Focal Fossa)
  • Vim Version: NVIM v0.7.0, Build type: RelWithDebInfo, LuaJIT 2.1.0-beta3
  • UltiSnips Version: version 3.2 (05-Nov-2019) (up to date via Vim-Plug)
  • Python inside Vim:
    • :py import sys; print(sys.version): 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0], and
    • :py3 import sys; print(sys.version): 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  • Docker repo/vimrc:
@celdorwow
Copy link
Author

I solved it using a Python interpolation:

snippet tabu "Regular tabular" b
\\begin{tabular$1}`!p if t[1] == "x" or t[1] == "*": snip.rv=r"{\linewidth}"`{${2:cc}}
	$0X & X \\\\
\\end{tabular$1}
endsnippet

However, I am going to leave it open because I don't know if what happens with the transformation above is a bug or intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant