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

sh (posix shell) snippets require $ symbols to be escaped #1381

Open
seamyb88 opened this issue Nov 5, 2021 · 3 comments
Open

sh (posix shell) snippets require $ symbols to be escaped #1381

seamyb88 opened this issue Nov 5, 2021 · 3 comments

Comments

@seamyb88
Copy link

seamyb88 commented Nov 5, 2021

I'm using neovim, if that's important. I'm also only talking about the SnipMate snippets.

The $ symbols which are intended to be inserted into the text need to be escaped in the snippet definitions for sh snippets.

For example in the getopt snippet, the line

echo "Usage : $${0:0} [options] [--]

should be

echo "Usage : \$${0:0} [options] [--]

and even those $ symbols which don't precede a tab stop require this also.

@karangb
Copy link

karangb commented Jan 13, 2023

I'm facing a similar issue w/ PHP syntax. Let's say I have the following two snippets:

snippet foo
	$this // this was created via foo

snippet bar 
	\$this // this was created via bar

They produce:

this // this was created via foo
$this // this was created via bar

Is this expected?

@smjonas
Copy link
Contributor

smjonas commented Jan 16, 2023

@karangb Yes that seems to be expected behavior. The snipmate docs mentions the second case but does not specify what should happen when the $ is not escaped:

Anywhere in a snippet, a backslash escapes the character following it,
regardless of whether that character is special or not. That is, '\a' will
always result in an 'a' in the output. A single backslash can be output by
using '\\'.

@smjonas
Copy link
Contributor

smjonas commented Jan 16, 2023

Also this issue seems to be fixed in https://github.com/honza/vim-snippets/blob/master/snippets/sh.snippets and can be closed @honza @seamyb88

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

3 participants