Atom Editor Snippets - atom-editor

I have a simple snippet:
'.source.js':
'Console log':
'prefix': '>log'
'body': 'console.log($1)'
It worked as expected for a while, perhaps I installed a package or something, but now when I hit tab after typing >log the right brace doesn't disappear, giving me >console.log();.
How would one remedy this situation?

Related

How do you console.log in Atom?

I spent hours on this and can't find a way to do the most basic thing like put console.log("la"); in my code and print it inside Atom when i view the html with html preview package.
I used to have one called console-js and right click on the html preview to launch it, but now, right click does nothing, and this package has some bug that i can't fix Uncaught TypeError: Cannot read property 'getSelectedText' of undefined
I was offered a few packages that has nothing to do with my need :
Script
Console-log
Platformio IDE terminal
Console.
I just can't find a simple way to print a simple thing while running my code inside Atom ( means viewing an html page with Javascript).
Is there a package that do such a simple thing ?
Maybe you can use this:
View -> Developer -> Toggle Developer Tools

Atom Code Editor. Why is my code not in color?

I started using the Atom Code editor recently. During my last project, I installed a couple of tools to make my coding more interactive.
One of the features added color to my code which makes it easier to read.
However, I started a new project today and the code is all white on a dark background. How do I color my code?
I have attached two screenshots of the colored code and the non colored code just to illustrate what I mean but its pretty straightforward.
Atom might not be recognizing the syntax of your code immediately. Check the bottom right corner of the screen to make sure atom has the correct language/file extension selected. You can manually select this if atom doesn't do it automatically. You might also need to install some new packages if atom isn't recognizing your code.
Use ctrl+shift+l to open the language selector, and select the auto-detect option.
I had the same problem. Try switching to HTML(Go) in the bottom right corner. It's between UTF-8 and Github.
Why isn't anybody mentioning the file extension?
Your "Project Greg.html" is HTML.
But "Random Quote Machine" has NO extension.
This is why the syntax isn't showing.
The current version of Atom I'm running as of Oct 2018 seems to identify code by tags. So even if I select HTML manually, unless the file has <html> tag, it still doesn't mark it as HTML. I just add redundant commented out <!-- <html> --> tag in the beginning of the file and it does the trick.
You may need to install a new package for Atom. You can find different language packages for Atom here: https://atom.io/packages
For example, for React.js, install the react package.
In your terminal, type this command: apm install react
More info for react packages:
https://atom.io/packages/react
https://orktes.github.io/atom-react/
Check the bottom right corner of the screen to make sure atom has the correct language/file extension selected
If your file has extension HTML or ejs (.html, .ejs) language-ejs package can 't recognize those file.In the bottom right corner of the screen, change the HTML to ejs or javascript, then the atom can recognize that the code your write is parts of ejs. NOte, you need to install language -ejs package first.
Follow the steps:-
File->Settings
Select 'Core' from left pane.
Change color profile to "Use sRGB color profile".
Restart 'Atom'.
Make sure the beginning identifies the file as a html document. I had this problem and just added <!DOCTYPE html> as the very first line and it worked.
Maybe this will helps for someone, but if you tab once this line: <!DOCTYPE html> and it will show coloured HTML code
If the langage set is already the right one,and the code stays grey unless you directly edit it, just try setting another langage then switch back. It worked for me after Atom refused to color an entire copy-pasted HTML page.
I am a very newbie but wanna share what worked for me. Please don't judge me strictly.
Since I work only in Python, it is very convenient to change the grammar to Python every time. How to make it automatic:
File->Settings (or use Ctrl+Comma)
Click Open config folder
Click on styles.less
After all the code, write exactly this source.python {
}
Save
Restart Atom.
You're all set.
Hope this was helpful, couldn't find this solution elsewhere.
The !DOCTYPE html did not change the color for me but in the bottom right is :
CRLF UTF-8 HTML GitHub Git(0) menu options. I selected HTML and in the popup window selected AUTO. The color returned instantly.

Atom snippets in assembly not working

So I use Atom, and I use Snippets. I used it before for writing cpp code, and it worked perfectly. Now I wanted to add few Snippets for assembly language.
Here is the relevant part of my snippets.cson:
'.source.s':
'movl':
'prefix': 'movl'
'body': 'movl ${1:SOMETHING}, ${2:%eax}'
Snippets for cpp work perfectly, but snippets for assembly do not work. I've got .s file, and when I type movl, it appears on the popup, but then I use tab, it just writes down movl. How can I fix this?
As far as I can tell from a look at language-assembly, the scope should be .source.assembly (it can be more specific, e.g. .source.assembly.asm.x86.intel).
When in doubt, you can always expose the current scope from the command palette.

What's wrong with my Atom Editor Snippet?

I'm getting to know Atom. I tried to make a snippet with the following format:
'text.html.basic':
'Comment Class':
'prefix': '<.'
'body': '<!-- .$1 -->'
But when I type <. then the tab key, nothing happens. Why not?
Atom currently only supports alphanumeric characters for snippet prefixes, see the open issue at https://github.com/atom/autocomplete-snippets/issues/56
Try using a prefix such as "comment" and it should work. I unfortunately don't know a better workaround.

How to bookmark code in XCode 4?

I couldn't find a way to put a bookmark inside the code in XCode 4. I know about the #pragma mark thing but it's not what I'm looking for. What I need is something that I can put and remove with a mouse click and navigate amongst with next and previous, like in VS.
Is there anything that I'm missing?
Bookmarks seem to have gone the way of the dinosaur in Xcode 4. This wouldn't have been so bad had the jump-to-bookmark popup above the editor in previous versions not also disappeared. The best replacement currently seems to be to use breakpoints (disabled individually, of course) and navigate with the Breakpoint Navigator.
Shortcut to breakpoints is Cmd + 8. Once there use arrow keys
File a bug report at http://bugreporter.apple.com if you feel something like this should be brought back.
Write below comment in your source file that you want bookmarked.
//<##>
And you can navigate to next / previous with: '^/' or '^?'
<##> means "placeholder of code snippet"
^/ means "jump to next placeholder"
^? means "jump to previous placeholder"
thanks
Another option, if anyone is still interested. The following directives will both produce a compiler warning that you can use as a bookmark:
#pragma message "<# message #>"
or
#warning <# message #>
If you want to place bookmarks using your mouse: create a code snippet with one of the 2 directives above. Drag & drop it to the line in your source file that you want bookmarked.
Navigate to next/previous with: Cmd-' and Cmd-Shift-'
In Xcode 4.4, if you leave a comment with this format:
// TODO: Your text here
it will be added as a listing in the jump bar alongside the list of methods in your current file, and then you can jump straight to that comment from that menu.
The simplest technique is to use a comment prepended by // TODO and then search, which allows you to jump through the issues from the navigator. Pretty hard to beat that technique.
I personally don't like using break points for bookmarks because it is not easy to enter notes. I use breakpoints as breakpoints, and prefer not to mix them up with bookmarks.
Anyhow, if you want to get a bit fancier you could get xcode to generate warnings // TODO: some message or // FIXME: some message that can be navigated in the issue navigator. I took the instructions below from this site:
Instructions
Head over to your project's item in the Project Navigator (usually at the very top)
Find your target in the list of targets on the left, select it
Head over to the "Build Phases" tab.
Click the "Add Build Phase" in the bottom right of this screen.
In the editor that appears insert the bash script shown below.
Now just build and you'll see all your //TODO: and //FIXME: comments have become warnings. I love this technique, it might not be right for everyone, but hope it helps someone.
Bash Script For "Run Script" Build Phase
KEYWORDS="TODO:|FIXME:|\?\?\?:|!!!:"
find "${SRCROOT}" ( -name ".h" -or -name ".m" ) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
You'll also be able to click on each of the warnings in the issue navigator to go right to the file and point in your code where you left the original //TODO: or //FIXME:
Extra pro tip: Make sure you're using phrases to describe your //TODO: comments like //TODO: Handle this error gracefully, and things like that. The phrases will show up in the issues list beside each warning.
Credit for the little tidbit should go to "Tim" on the Cocos2D forums, (found after Googling for a bit), I believe his solution originally was intended for Xcode 3 and didn't work if you had spaces in your path name, my script here doesn't have those restrictions, still he should get full credit here's his original post.
Like npellow's answer to this question of mine, appCode by JetBrains has also made this possible. So, this may be another reason to use appCode instead of Xcode4, except that it won't be free later in time.
My method:
type in grammar error code in the previous line.....
After changing something in other place, I can go back to the previous place because the grammer error line will show a red line in the right side scroll bar. It indicate the place.
It is not elegant but unless there is a bookmark feature, this is the way i am using at the moment
You can install an Xcode plugin called "XBookmark".
This plugin provide features below :
Toggle Bookmark
Show Bookmarks
Next Bookmark
Previous Bookmark
How to install XBookmark:
Install Alcatraz.
Search XBookmark from Window->Package Manager and click Install.
Restart Xcode.
Now, you can see menus about bookmarks in the Edit Menu.
PS : This plugin is open source.

Resources