Bitbucket+sublime Text 2 Configures a cross-platform NODEJS development environment

Source: Internet
Author: User
Tags stdin sublime text

Because I this application will be developed on three computers, Winxp,win7,mac, so the development environment to consider two issues, one is synchronization, but software differences, synchronization I use Git way to the code to, before changing the computer before the push. Address: Https://

Software aspects I suggest NODEJS IDE with sublime Text 2, why use this, I mainly use the following characteristics of his: code highlighting, automatic completion, rich Plug-ins, Cross-platform

So the artifact, sure to use the next try, download the address here, it is recommended or not to install Nodejs Plug-ins, will interfere with the original automatic completion function.

I installed 3, jade:jade syntax highlighting, bracket highlighter: parentheses, quotes matching, JS format:js format. Ps:windows under the proposal to replace CMD with Powercmd.

Sublime Text 2 Getting Started and tips

Read nettuts+ to Sublime Text 2 Introduction, immediately excited, as the author Jeffrey Way said: "Eternal Destruction Duke" all released, TextMate 2 haven't hair ", you can expect it?" The negative attitude of textmate developers is no longer tolerable. And as a cross-OS X, Linux and Windows three systems platform of the text editor, Sublime text 2 function of the day, great to take textmate and generation of momentum,

The following will nettuts+ this article to do a rough translation, is not exhaustive, as a primer is enough. The following are mainly based on the Mac version, but for Windows and Linux version is also interlinked.

Change a engaging dot icon

Sublime Text 2 is still in beta, and the default black square icon doesn't look good enough, and Nate Beaty has made a nice substitute.

the replacement method under Mac:

Locate Sublime Text 2 in the application directory, hold down CTRL and click, and select "Show Package Contents" from the pop-up menu.
Enter the contents/resources/directory and replace Sublime Text 2.icns with the newly downloaded icon.

trying to develop a version

Sublime Text 2 is currently active and it is recommended that you download and install the dev version if you want to try the latest features.

Quick Command Panel

Like TextMate, Sublime Text 2 also provides a convenient way to invoke command Palette (command panel). Invoke method: Directly in the Tool menu, select command Palette, or use the shortcut key: Shift + command + P, enter the command name (in the letter) can be real-time search for the corresponding commands, options, snippet and Syntex, press ENTER can be directly executed , reducing the trouble of finding.

Real-time file switching

Press Command + P (MAC) or Ctrl + P (Windows), enter the file name you want to switch to, do not have to press the ENTER key, the target file has been shown in front of, although Vim with Peepopen can also achieve the same function, but the speed is far from so fast.

Jump at Whim

The reason why Cmd+p is called Goto anything is not an undeserved name:

You can quickly jump to any file in the current project with command+p to match the keyword.
With Command+p @ (or command+r) can quickly list/jump to a function (it is very cool in the markdown is matching to the title, but also with the indentation!) )。
Use the command+p after # to search in the current file.
After Command+p: (or ctrl+g) plus number can jump to the appropriate line.
And the cool thing is you can use command+p plus some keywords to jump to a file and add @ To list/jump to a function in the target file, or add a # to search in the target file, or add: and numbers to jump to the corresponding row in the target file.

multiple selection (multi-selection)

Multiple-selection features allow multiple cursors to be present in the page, making it easier for many tasks that would otherwise require regular expressions, advanced search, and replacements. Look at the examples provided by nettut+ may be more intuitive:

There are several two ways to activate multiple selections:

Hold down Command or ALT, and then click where you want the cursor to be in the page.
Select a few lines of text, and then press Shift + Command + L.
By repeatedly pressing Control/command + D, you can add the full text to the same word as the current position of the cursor, and press ALT+F3 (Windows) or ctrl+command+g (MAC) to select all the same words at once.
Press the middle mouse button to select vertical columns, or you can enter multiple editing states.

Indent indicator (Indent Guide)

Indentation instructions have been integrated into Sublime Text 2, and no plug-ins need to be installed.

Indentation indicates that this small feature can make the hierarchy of code more clear, in Sublime Text 2, you can use a plug-in to achieve this functionality.

Installation method:

Download the Indentguides plugin.
After decompression, rename the folder to Indent guides and place it into the Packages directory. An easy way to find the Packages directory is to select Browse Packages in the Preferences menu of Sublime Text 2.
Restart Sublime Text 2

Install package control (Package controls)

Is the method of installing Plug-ins in the previous article cumbersome? In fact, as with TextMate can be installed Bundle, Plugin, Sublime Text 2 also has a good extension, this is the installation package (Package), as well as textmate have to install, upgrade, uninstall Bundle Getbundles , Sublime Text 2 also has plug-ins for Package controls: Sublime Package control. With Sublime Package control, installation, upgrades, and uninstall Package also become effortless.

To install the Package control method:

Open Sublime Text 2, press CONTROL + ' pull Console

Paste the following code into the command line and enter:

Import Urllib2,os; pf= ' Package control.sublime-package '; IPP = Sublime.installed_packages_path (); Os.makedirs (IPP) if not os.path.exists (IPP) else None; Urllib2.install_opener (Urllib2.build_opener) (urllib2. Proxyhandler ())); Open (Os.path.join (IPP, PF), ' WB '). Write (Urllib2.urlopen ('' +pf.replace (', '%20 ')). Read () ); Print (' Please restart Sublime Text to finish installation ')

Sublime Text 3 Please use the following code:

Import Urllib.request,os; PF = ' Package control.sublime-package '; IPP = Sublime.installed_packages_path (); Urllib.request.install_opener (Urllib.request.build_opener (Urllib.request.ProxyHandler ())); Open (Os.path.join (IPP, PF), ' WB '). Write (Urllib.request.urlopen ('' + pf.replace (', '%20 ')) . Read ())

Restart Sublime Text 2, if you see Package control in Preferences-> Package settings, the installation is successful.

The method of installing Package using Package control is detailed in the places that are used later.

Snap To

For some like neat-looking yards, seeing this may be intolerable:

var Joe = ' Joe ';
var johnny = ' Johnny ';
var quaid = ' Quaid ';

Be sure to change it to feel at ease:

var Joe = ' Joe ';
var johnny = ' Johnny ';
var quaid = ' Quaid ';

TextMate also has such a function (Option + Command +]) can automatically achieve the above alignment process, and in Sublime Text 2, a Sublime alignment plug-in can also be easily implemented.

This plugin is installed using the Package control:

Press Shift + COMMAND + P to pull up the command panel.

Enter install Package control:install Package option and press ENTER.

Locate the alignment in the list and press ENTER to install it.

Restart Sublime Text 2 to make it effective. You can now do the Zicao by selecting the text and pressing Shift + COMMAND + a Ctrl + command + A.

This method can be easy to install more plug-ins, although the current installation source is not a lot of plug-ins, but I believe that the future will be richer.

Vim Mode

Yes, the Sublime Text 2 dev version already supports Vim's editing mode, and if you prefer Vim's editing mode, you can activate Vintage mode in the following ways:

Press Shift + COMMAND + P to pull up the command panel.

Enter the settings user to pull up the preferences:settings-user and press ENTER.

The above two steps can also be directly with CMD +, completed.

This will open a preferences.sublime-settings file, if it is the first time, it should be an empty file, paste the following text in:

"Ignored_packages": []

Save this file, then press the ESC key, and then press some of your familiar Vim commands, is not very cordial?

Non-jamming mode (distraction free modes)

Now the editor doesn't seem to be justified in Sublime Text 2, just press CONTROL + Shift + Command + F or select Enter Distraction free mode in menu View You can go into this UI minimization mode. If you are using Mac OS X Lion, Sublime Text 2 also supports Lion's native Full-screen mode.

You can make some settings on the anti-jamming mode by modifying the "Preferences"-> "File settings-more"-> "Distraction Free-user":

' Line_numbers ': false,//whether line number is displayed
' Gutter ': false,//whether to display the edge columns
' draw_centered ': true,//is centered
"Wrap_width": 80,//Line width (unit: character)
' Word_wrap ': true,//whether to wrap lines automatically
' Scroll_past_end ': true//scrolling can exceed end

TextMate Bundle

Sublime Text 2 is a great force to support some of the textmate Bundle.

Sublime Text 2 has good native support for snippet in TextMate Bundle, and it can be used in Bundle directory. However, the command in Bundle is not supported, in addition, the textmate color theme [1] can also be used directly in the Packages directory. It is estimated that with the Sublime Text 2 getting more and more hot, more textmate Bundle will be transplanted.


The theme here is different from the Color Scheme for code, which refers to the subject of the Sublime program itself, which is currently installed by Ian Hill's Soda.

Because the source has been added, the installation of this theme can also be Package control, very convenient. At present, the Soda theme offers two styles of light and shade.

To activate the method, also modify the Preferences:settings-user:

Press Shift + COMMAND + P to pull up the command panel.

Enter user settings to pull up the preferences:settings-user and press ENTER.


Add the following code to activate the Soda Light theme:

"Theme": "Soda light.sublime-theme"

Add the following code to activate the Soda Dark theme:

"Theme": "Soda dark.sublime-theme"

Save in effect.

command-line tools

Like TextMate and Macvim, Sublime Text 2 also provides a handy command-line tool for quickly calling Sublime Text 2 programs to open files/directories/projects through a terminal.

To use command-line tools, you need to create a symbolic link to run in a terminal (

Ln-s "/applications/sublime Text" ~/bin/subl

Then run Subl--help to see how the SUBL command is used:

Edit the specified file using: subl [parameters] [file]
Or: Subl [parameters] [directory] Open the specified directory
Or: Subl [parameters]-Edit stdin

Available parameters:
--project < project: Reading specified items
--command < command: Run the specified command
-N or--new-window: Opens a new window
-A or--add: adding a folder to the current window
-W or--wait: Wait for file to close before returning
-B or--background: Do not activate program window
-S or--stay: Keep the program window active after closing the file
-H or--help: Show this Help
-V or--version: Display version number

The--wait parameter is used when reading stdin. --stay allows you to not return to the terminal after the file is closed (for a single file only).

You can open to a more specific location by adding a ': line number ' or ': line number: column number ' suffix to the file name.


In the process of trial Sublime Text 2, "fast" and "shun" is to give Lucifr the strongest feeling, just like the Chrome browser, Sublime all kinds of operations give people a very smooth feeling. Good Chinese support is also textmate not have, although the current number of plug-ins and quality can not completely replace the textmate, but it is very much to look forward to. The only thing that is tangled is the price, $59 's registration price is really not cheap (obviously according to TextMate's $58 add a set of it), fortunately the current testing phase can be unlimited trial.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.