Skip to main content

Sublime Guide

Free2015-05-28#Tool#前端IDE#sublime#sublime插件

Installed Sublime a long time ago because I heard colleagues were using it. Recently finally decided to give up Notepad++ and switch to Sublime

Preface

I've been using Notepad++ all along, and it felt pretty good. Later I discovered that people around me code much faster than I do, which made me a bit unconvinced, so I went looking for plugins, planning to find a better code completion plugin to improve efficiency. The result of searching around was uninstalling npp and switching to Sublime..

P.S. Before that I was using Dreamweaver, but later discovered it would inexplicably crash when editing source code files with thousands of lines, which was unbearable, so I switched to the lightweight npp. Sublime was also installed early on, but I never used it because I felt the interface wasn't as pleasing as npp.

1. Advantages of Sublime

Actually, the most direct reason for giving up npp was that I couldn't find a plugin that could generate comment templates (similar to Eclipse's Alt + Shift + j). Comments are very important in frontend development, and it's absolutely unacceptable not to have a convenient plugin.

During the plugin search process, I discovered that many plugins are for PHP/Python, not many for frontend, and I simply couldn't find any good ones. As for code completion/comment generation, perhaps it could be achieved through the QuickText plugin, but it's still relatively troublesome.

The most attractive thing about Sublime might be the super convenient functionality provided by Ctrl + p: input @ to display functions/variables, input :n to jump to line n. These few simple functions require at least 2-3 plugins in npp, and one more plugin means having to remember another shortcut key combination.

Of course, npp also has highlights, such as the built-in Launch in Chrome/IE/FF, while Sublime requires installing plugins to achieve this.

The biggest reason for giving up npp is that npp's frontend plugins are not sufficient, many plugins haven't been updated for a long time, while Sublime has many frontend plugins originally, and they're becoming more and more numerous.

P.S. Don't worry about the Sublime licensing issue, it's said you can use the trial version permanently, it just occasionally pops up a prompt box. Of course, there's also something called a registration code..

2. Installing Sublime

Official website: http://www.sublimetext.com/

Download and install, currently the stable version is 2.0.2, registration code as follows:

----- BEGIN LICENSE -----

Andrew Weber

Single User License

EA7E-855605

813A03DD 5E4AD9E6 6C0EEB94 BC99798F

942194A6 02396E98 E62C9979 4BB979FE

91424C9D A45400BF F6747D88 2FB88078

90F5CC94 1CDC92DC 8457107A F151657B

1D22E383 A997F016 42397640 33F41CFC

E1D0AE85 A0BBD039 0E9C8D55 E1B89D5D

5CDB7036 E56DE1C0 EFCC0840 650CD3A6

B98FC99C 8FAC73EE D2B95564 DF450523

------ END LICENSE ------

3. Common Shortcuts

1. Universal Command

  • Ctrl+P, universal command panel, directly type letters to search project files, very fast.

  • Ctrl+P+input @, js lists all function names of this file\html lists all ids.

  • Ctrl+P+input:N (N is a number), directly jump to line N.

  • Ctrl+Shift+F, quickly search for keywords in the project, similar to ack-grep functionality.

3. Comment Code

  • Ctrl+/ comment entire line (if content is already selected, same effect as "Ctrl+Shift+/")

  • Ctrl+Shift+/ comment selected content

4. Fold Code

  • Ctrl+Shift+[ fold code

  • Ctrl+Shift+] unfold code

  • Ctrl+KT fold attributes

  • Ctrl+K0 unfold all

5. Split Panes

  • Alt+Shift+1 single pane browse mode

  • Alt+Shift+2 vertical two-pane browse mode

  • Alt+Shift+8 horizontal two-pane browse mode

6. Bookmarks

  • Ctrl+F2 set bookmark

  • F2 next bookmark

  • Shift+F2 previous bookmark

7. Selection

  • Ctrl+L select entire line (hold-continue selecting downward lines)

  • Ctrl+KK delete from cursor to end of line

  • Ctrl+Shift+K delete entire line

  • Ctrl+Shift+D copy the line where cursor is located, insert before that line

  • Ctrl+J merge lines (when multiple lines to be merged are already selected)

  • Ctrl+KU change to uppercase

  • Ctrl+KL change to lowercase

  • Ctrl+D select word (hold-continue selecting next identical string)

  • Alt+F3 select all identical text at once for simultaneous editing

  • Shift+right mouse button select all identical text at once for simultaneous editing

  • Ctrl+left mouse button can manually select multiple locations of text to edit simultaneously

  • Ctrl+M cursor moves to start or end position inside brackets

  • Ctrl+Shift+M select content inside brackets (hold-continue selecting parent brackets)

  • Ctrl+Z undo

  • Ctrl+Y redo undo

  • Ctrl+M cursor jumps to corresponding bracket

  • Alt+. close current tag

  • Ctrl+Shift+A select parent tag pair at cursor position

  • Ctrl+U soft undo

  • Ctrl+T swap words

  • Tab indent auto-complete

  • Shift+Tab remove indent

  • Ctrl+Shift+↑ swap with line above

  • Ctrl+Shift+↓ swap with line below

  • Ctrl+K Backspace delete from cursor to beginning of line

  • Ctrl+Enter insert line after cursor

  • Ctrl+Shift+Enter insert line before cursor

4. Useful Plugins

1. Sublime Package Control

Plugin manager, your waist will hurt if you don't install it

2. GBK Encoding Support

If you open a txt file and find Chinese garbled text, then you may need this

3. Emmet

zenCoding upgraded version

A tool to protect your fingers, something similar to Markdown, specific syntax

Usage method: shortcut key ctrl+e

4. BracketHighlighter

Highlight matching brackets

Usage method: automatic

5. DocBlockr

Comment template generation tool (this is why I abandoned NPP)

Usage method: input "/**" + enter to bring up (only effective on the line above a function)

6. js Format

Need this to read other people's code

Usage method: shortcut key ctrl+alt+F

With these 6 plugins above, it should be very good

References

Comments

No comments yet. Be the first to share your thoughts.

Leave a comment