atom / snippets

Atom snippets package
MIT License
205 stars 100 forks source link

Snippet with $1 at beginning of line keeps following whitespace #195

Closed rbe closed 6 years ago

rbe commented 8 years ago

There's an issue with expanding variables in a snippet. The following snippet:

'.source.asciidoc':
  'Whitebox Template':
    'prefix': 'whitebox'
    'body': """
    $1 foobar
    line 1
    line 2
    line 3
    """

will produce text where every line is preceeded by a space:

Bla foobar
 line 1
 line 3
 line 3

The space after the $1 in the first line is kept for every line.

proxeIO commented 7 years ago

I have the same issue, easy work around for the time being is to use ${1:whatever} in place of $1

mossarelli commented 7 years ago
'.text':
  'Whitebox Template':
    'prefix': 'whitebox'
    'body': """
$1 foobar
line 1
line 2
line 3"""

creates:

 foobar
 line 1
 line 2
 line 3

while:

'.text':
  'Whitebox Template':
    'prefix': 'whitebox'
    'body': """
line 1
line 2
line 3"""

creates:

line 1
line 2
line 3
50Wliu commented 6 years ago

Thanks for taking the time to contribute!

We noticed that this is a duplicate of #213 which will be fixed by #245. You may want to subscribe there for updates.

Because we treat our issues list as the Atom team's backlog, we close duplicates to focus our work and not have to touch the same chunk of code for the same reason multiple times. This is also why we may mark something as duplicate that isn't an exact duplicate but is closely related.

For information on how to use GitHub's search feature to find out if something is a duplicate before filing, see the How Can I Contribute? section of the Atom CONTRIBUTING guide.