Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Snippets that overwrite existing ones #2695

Closed
siannopollo opened this issue Jun 20, 2014 · 17 comments
Closed

Snippets that overwrite existing ones #2695

siannopollo opened this issue Jun 20, 2014 · 17 comments
Labels

Comments

@siannopollo
Copy link

The Language Rspec package comes with it's set of snippets, and those are fine, except that they use double quoted strings (I know, I know, roll your eyes so we can get past that part :-). Anyway, I set up my own snippets in my snippets.cson file (the one accessed via Atom > Open Your Snippets) that overwrite some of the existing Rspec ones.

When I first open up Atom and try to use one of my custom snippets they don't seem to be loaded and the Language Rspec ones are used instead. If I then open up my snippets.cson file and hit cmd+s Atom picks them up and starts using my snippets.

@izuzak
Copy link
Contributor

izuzak commented Jun 23, 2014

@siannopollo I suspect that you're hitting this issue: #1867 Could you perhaps take a look and let me know if it is the same problem, or if not -- clarify what the difference is? Thanks!

@siannopollo
Copy link
Author

@izuzak That issue seems to be separate from this one, since I can reproduce this error without removing the snippets.cson file. And I'm only seeing this problem with snippets that overwrite snippets introduced by a package. Any of my custom snippets, for which there are no other competing tab triggers within the same scope, work without a problem.

I can reproduce this error by:

  1. Add a snippet that overwrites an existing snippet (I've been using the Rspec snippets as my example)
  2. Quit Atom
  3. Start Atom
  4. Trigger the newly added snippet, and the Rspec version will win out
  5. Open the ~/.atom/snippets.cson file and Save the file (no changes need be made)
  6. Trigger the snippet again and it will use the customized version

@izuzak
Copy link
Contributor

izuzak commented Jun 23, 2014

Ahhh, thanks @siannopollo -- totally neglected that fact because I was focused on the other issue. Appreciate the clarification 🙇

@tregusti
Copy link

I have this problem too. Any workaround except cmd+shift+p opsnip enter cmd+s?

@bclinkinbeard
Copy link

Is this going to be addressed? Pretty annoying to not be able to modify snippets I use several times a day like console.log

@benogle
Copy link
Contributor

benogle commented Jul 17, 2015

@bclinkinbeard I am able to override them

Add this to your snippets.cson, then reload, and open a coffee file:

'.source.coffee':
  'log':
    'prefix': 'log'
    'body': 'console.omgwowlog $0'

@bclinkinbeard
Copy link

That works, but overriding for JS files doesn't seem to. I have tried both of the following to avoid the semi-colon to no avail.

'.source.js':
  'log':
    'prefix': 'log'
    'body': 'console.log($1)'

and

'.source.js':
  'console.log':
    'prefix': 'log'
    'body': 'console.log($1)'

@benogle
Copy link
Contributor

benogle commented Jul 18, 2015

Not sure. This works for me in js:

'.source.js':
  'log':
    'prefix': 'log'
    'body': 'console.OMGlog($1);$0'

Did you reload?

@bclinkinbeard
Copy link

That does not work for me, even if I completely quit Atom and reopen.

@benogle
Copy link
Contributor

benogle commented Jul 18, 2015

What else is in your snippets file? What if that is the only thing? Try atom --safe? I assume you're on the latest (1.0.2).

@bclinkinbeard
Copy link

OK that is weird. The only other thing in my snippets file is this, which is what is breaking it.

'.source.js':
  'require()':
    'prefix': 'req'
    'body': 'var ${1:module} = require(\'${2:$1}\')$3'

If I remove that, the log snippet works.

@benogle
Copy link
Contributor

benogle commented Jul 18, 2015

Did you have 2 top level .source.js keys? Like json, the second will overwrite the first.

@bclinkinbeard
Copy link

Ah jeez, that was in fact the problem. Sorry about that, and thanks for helping me sort it out.

@devunwired
Copy link

Did you have 2 top level .source.js keys? Like json, the second will overwrite the first.

Oh, man. That really needs to be documented here. Just spent an hour trying to figure out why none of my snippets except that last one was getting picked up…

@benogle
Copy link
Contributor

benogle commented Jul 28, 2015

Docs added in atom/flight-manual.atom.io#102. I'm going to close this as it seems to be a poorly-communicated limitation.

@jsgv
Copy link

jsgv commented Jan 5, 2016

I am having similar issue. Can not override the p expand. The html5 snippet works fine.

'*':
  'paragraph':
    'prefix': 'p'
    'body': '<p>$1</p>'
  'html5':
    'prefix': 'html5'
    'body': '<!DOCTYPE html>\n<html lang="en">\n<head>\n\t<meta charset="utf-8">\n\t<meta http-equiv="X-UA-Compatible" content="IE=edge">\n\t<meta name="viewport" content="width=device-width, initial-scale=1.0">\n\t<meta name="description" content="">\n\t<meta name="keywords" content="">\n\t<title>${1:title}</title>\n</head>\n\n<body>\n</body>\n</html>'

@lock
Copy link

lock bot commented Jan 18, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants