I justed started learning JavaScript. While doing that, I got tired of embedding my JavaScript code into an HTML document in order to run it in the browser. I thought it would be nice to just run my scripts right in Sublime's console, so I wouldn't have to leave the editor. Therefore I was trying to create a JavaScript build system, since Sublime doesn't come with one.
My idea was to use Node.js as the JavaScript interpreter. I installed it with the package manager of Linux Mint. As far as I can say it works just fine. Let's say I have a file test.js containing the following line of JavaScript code: console.log("Hello World");
When I run nodejs /path/to/test.js in my console, I get: Hello WorldHowever, I don't get this to work with Sublime. I created a new Build system by clicking Tools / Build System / New Build System. I then typed in the following lines: "cmd": ["nodejs", "$file"] As far as I know, this one line is the JSON representation of the following command: nodejs /path/to/current/file.ext Like I said, if I run this manually in the console, it works just fine. If I press F7 in Sublime, which is the shortcut for Build, Sublime's console shows up. It's empty though.
There's another weird thing. Even though the (non-existing) output of Sublime's console indicates that the build system isn't configured to correctly work with Node.js, I got some Node.js errors displayed when I accidentally tried to run non-JS files such as the Node.sublime-build file. This is the output displayed in Sublime's console: /home/baerenfaenger/.config/sublime-text-2/Packages/User/Node.sublime-build:2 "cmd": ["nodejs", "$file"] ^
Mac users, type which node in terminal. It outputs the path of the node executable, which in most cases is /usr/local/bin/node. Now create a new build system (Tools > Build System > New Build System) with the following settings in Sublime Text.
Most of the answers from this thread is correct but none is complete and at least no answer tells about how to kill existing Node process even if you are able to run node in sublime. So eventually if either of above approach worked for you, You will end up manually killing Node always.
would work. However there is no way to stop the server than.I've found out the best solution which opens server in new console and the closes it automatically.I also works fine with supervisors or node-inspector
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
I downloaded the sublime text editor but can't seem to find a way to view the webpage I am coding in html and css. There isn't a view button like there is in the workspace I used in the previous lesson.
I know this is late, but I own Sublime Text 3. It looks like with the latest update, "view in browser" is by default installed, so no need to install a third-party package. Anyway, on Windows, I use this:
If your using a third party editor you'll likely need to do something like double click the actual index.html file in your folder or right click and -view with- Internet Explorer or Google Chrome for example.
Bookmarks in Sublime Text are similar to Markers in BBEdit. They are as the name implies, marks that refer to specific text in a document. BBEdit Markers are more advanced since they can be titled and browsed as a list. However, Sublime Text 2 provides a sufficiently powerful system that's it is worth trying out.
While I am writing, I may decide to revisit some text later. I know I'm not happy with the current material but I don't want to get bogged down in editing when I could be writing. Bookmarks are a way to mark the text and move on.
I continue to write or edit until I want another bookmark. I then repeat the process with the new selection. When I am done, the document will have several markers along the left margin indicating the lines that contain bookmarks.
While Sublime bookmarks are not as powerful as BBEdit markers, they are a nice option in an incredibly powerful text editor. I use the bookmarks while I write and while I edit and I am happy that they are there. Debating between using BBEdit and Sublime Text is a great position to be in.
Bookmarks are available in the default installation of Sublime Text 2. They are configured to use the F2 key. I changed mine to use the F3 key instead. If you want to use the F-keys, make sure you change or turn-off the OS X keyboard shortcuts that are using them.
Over the last couple of months, I've been writing a lot of Markdown, primarily for these blog posts. I've tried various text editors, but haven't been entirely happy with the writing experience until last week when I discovered two excellent packages for Sublime Text. Here's the setup which I used to write this very post and which I'll be using to write Markdown from now on.
If I need to sit down and focus on my writing, I like to enter Sublime's distraction free mode, which then switches to fullscreen and hides everything but the current file's content. That makes it a lot easier to stay focused on the task of writing:
Luckily, the author of the Monokai Extended package, Jon Schlinkert, provides a package named Markdown Extended for making code blocks pretty, too. With that package installed, you can enjoy language-specific syntax highlighting:
The package "LSP" is an acronym for Language Server Protocol. This is a specification for the communication protocol for use between text editors or IDEs and language servers - tools which provide language-specific features like autocomplete, go to definition, or documentation on hover.This package acts as an interface between Sublime Text and your language server, which means that to obtain these features you need to install a server for your language first.Language servers can be provided as standalone executables or might require a runtime environment like Node.js or Python.Many new concepts not native to Sublime Text are in use. For an overview of these concepts, please see the Features page.
Scan the console output for errors?
Do you mean the browser console window in developer tools? And which way should I open the browser to then inspect the console as my Sublime text 3 will no longer open in chrome?
We can now start the Xdebug session to see if everything is set up properly. In the menu, click on tools -> Xdebug and click on start debugging (launch browser). You will notice that your website is opened up and that ?XDEBUG_SESSION_START=sublime.xdebug is added to the end of the URL. This will start the xdebug session. In Sublime, some extra panels appear where debug information will be shown, after you have set one or more breakpoints.
We can add a breakpoint by clicking with our right mouse on a line, going to Xdebug and then clicking on add/remove breakpoint. A marker will be added to the line gutter to indicate that a breakpoint has been set.
We open up our browser again and continue with the session we just started. You will notice that as soon as you go to the page where the breakpoint is, the page will stop loading. If you now open up Sublime, you will see a lot of information shown in the Xdebug panels.
In the context, you will see all global variables, but also the variables you defined yourself. You can click on these variables to see exactly these variables are holding. For instance, in the screenshot below, I clicked on the $_SERVER variable.
So our application halted and now we can look through the variables defined. However, we are done and we want to move on. What now? When you right mouse click once again and hover over the Xdebug menu, you will have several options:
In this article we saw how we could integrate Xdebug with Sublime and made sure we understood how to debug. Almost every IDE suitable for PHP can integrate with Xdebug. If you are interested in debugging like this in Netbeans, have a look at the article mentioned in the introduction. Are you using breakpoints? Or are you using PHP functions like var_dump to get your debug data? Let us know in the comments below!
Did you know that there is a fantastic online repository and discovery tool for Sublime Text packages? The plugin community for Sublime is huge, and there are more packages being added all the time. Here are the handful of packages that I consider must-haves for Rails development.
I use AdvancedNewFile to quickly create files at any level of a project folder hierarchy without needing to take my hands off the keyboard. This is really useful for Rails, where even a brand new project contains dozens of directories.
Just press CMD-OPT-N and type the path (relative to the root of your project) of the file you want to create and press RETURN. AdvancedNewFile supports tab-completion, so you can quickly expand existing directory names.
Sublime ships with autocomplete behavior, but it is limited to completing strings that exist in the current editor. With All Autocomplete installed, all open files are searched for autocompletion candidates.
Programming involves lots of copy and paste, so I consider clipboard history to be essential. There are system-wide solutions, but Clipboard Manager gets the job done for Sublime Text. It keeps a history of all copied text, and allows me to use keyboard shortcuts to browse that history or to cycle through previously copied text.
This is an install-and-forget-it enhancement to Sublime that saves me keystrokes when writing multi-line code comments. When I hit RETURN while writing a Ruby comment, DocBlockr will helpfully indent and add the leading # on the next line. Works for other languages, too.
This is one setting that deserves a special note. I always thought that source code indexing required a fancy IDE or a separate plugin, like ctags. But no! Sublime Text 3 does indexing, and it works great with Ruby. Just make sure it is turned on:
59fb9ae87f