Sublime Text 3 using

Source: Internet
Author: User
Tags perl regular expression sublime text editor

Editor (Editing)

Sublime text Editor is very human-it is not like vim anti-human (although I also use vim, but I still want to say that Vim's shortcut set cliff even less metabolic products), a small number of shortcut keys can complete the majority of editing tasks.

Basic Editing (Editing)

↑↓←→That's right ↑↓←→ , no KJHL , (yes, I'm just in the groove vim, it's WSAD also better than this), paste cut replication is consistent with the system.

Ctrl + EnterAdds a row below the current line and jumps to that row, Ctrl + Shift + Enter adds a row above the current row, and jumps to that row.

Ctrl + ←/→The word-by-phrase movement, corresponding to the Ctrl + Shift + ←/→ word selection.

Ctrl + ↑/↓Moves the current display area, Ctrl + Shift + ↑/↓ moving the current row.

Select (Selecting)

One of the highlights of Sublime text is that it supports multiple choices-selecting multiple regions at the same time and editing them simultaneously.

Ctrl + DSelect the word with the current cursor and highlight all occurrences of the word, Ctrl + D select the next position where the word appears, and in the process of multiple selection, use Ctrl + K skip, use Ctrl + U to rollback, use to Esc exit multiple edits.

One of the big scenarios for multiple-choice words is renaming-which makes the code cleaner. Although sublime text cannot be renamed automatically like the IDE (for example, Eclipse), we can make it intuitive and easy to rename with multiple choice words + multiple edits:

Sometimes we need to edit all the rows of a region simultaneously, break Ctrl + Shift + L the current selection and edit it simultaneously:

There is a merge, Ctrl + J you can merge the currently selected area into one line:

Find & Replace (finding&replacing)

Sublime Text provides a powerful find (and replace) function, in order to provide a clear introduction, I will Sublime text search function divided into Quick Find , standard find and multi-file Find three types.

Quick Find & Replace

In most cases, we need to find other places where a keyword appears in the text, so we don't need to re-enter it again and search, we just need to use Shift + ←/→ or Ctrl + D Select the keyword, and then F3 jump to its next occurrence, Shift + F3 jump to its last occurrence position, You can also Alt + F3 Select all the locations where they appear (you can then make multiple edits, which is quick replacement).

Standard Find & Replace

Another common usage scenario is to search for a keyword that is known but not in the current display area, and you can use the Ctrl + F bring up search box to search:

and use Ctrl + H to replace:

Keyword Find & Replace

For ordinary users, a regular keyword search can satisfy their needs: After entering a keyword in the search box Enter , jump to the next position of the keyword's current cursor, jump to the Shift + Enter previous position, and Alt + Enter Select all the locations where it appears (again, you can quickly replace it).

Sublime text Lookup has different modes: Alt + C Toggle Case Sensitive (case-sensitive) mode, Alt + W toggle integer match (Whole matching) mode, in addition to Sublime Text also supports searching within the selected range (search in selection), which does not have a corresponding shortcut key, but can be automatically opened with the following configuration items.

"auto_find_in_selection": true

After that, the search within the range of the selected text will automatically open, with this function, local renaming (locally renaming) becomes very convenient:

Replace all matching keywords with the current keyword by replacing it with Ctrl + H a standard replacement, after entering the replacement Ctrl + Shift + H Ctrl + Alt + Enter .

Regular expression Find & Replace

Regular expressions are a very powerful text find & Replace tool that uses Alt + R toggle regular match mode on/off in Sublime text. Sublime text uses the Perl regular expression style in boost.

For space reasons, the regular expression is not described in detail, mastering Regex (Chinese translation: proficient in regular expressions) on the principle of regular expressions and the use of various languages are described in detail. There are also a number of excellent tutorials on the web for regular expressions ("regular expression 30-minute introductory tutorial" and MSDN Regular expression tutorials), as well as online test tools (Regexpal and Regexer).

Multi-File Search & Replace

Use Ctrl + Shift + F to turn on multi-file search & Replace (note this shortcut key and Sogou Input method of the simple shortcut keys have conflict):

Multi-File Search & Replace by default search/Replace in currently open files and folders, we can also specify files/folders for search/replace.

Jump (jumping)

Sublime text provides a powerful jump feature that allows us to seamlessly switch between different files/methods/functions. As far as my experience is concerned, no editor can go beyond sublime Text in this respect.

Jump to File

Ctrl + PLists the currently open file (or the file in the current folder), enters the file name, and then Enter jumps to it.

It is important to note that Sublime text uses fuzzy string matching (Matching string), which means that you can match by the prefix, initials, or part of a file name: For example, EIS , Eclip and Stupid both EclipseIsStupid.java .

Jump to Symbol

Although it is a text editor, Sublime text can index code symbols to some extent. Ctrl + Rlists the symbols in the current file (such as the class name and function name, but cannot drill down into the variable name), and Enter you can jump to it by entering the symbol name. In addition, you can use F12 quick jumps to the definition of the symbol where the current cursor is located (jump to definition).

Interestingly, for Markdown, Ctrl + R it is very practical to list its outline.

Jump to a row

Ctrl + GThen enter the line number to jump to the specified line:

Combo Jump

Ctrl + Pafter matching to the file, we can make subsequent input to jump to a more precise position:

    • @Symbol Jump: Enter @symbol symbol the location where the symbol is located
    • #Keyword Jump: Enter #keyword the location to jump to keyword
    • :Line number jump: input :12 jumps to the 12th line of the file.

So sublime text Ctrl + P calls it "Go to Anything", which is so useful that I don't think other editors can go beyond it.

The problem of Chinese input method

From the first edition of Sublime Text (1.0) to now (3.0 3065), the Chinese input method (including the Japanese IME) has a problem: the input box does not follow.

Currently, the official has not fixed this bug, the workaround is to install the IMESupport plug-in, and then restart the sublime text problem solved.

Folder (Folders)

Sublime text supports editing in folders, which is especially useful when editing code in a folder. In the File following Open Folder :

You'll find a sidebar on the right, which lists the files currently open for files and folders, uses the Ctrl + K, Ctrl + B Show or hide sidebar, and Ctrl + P quickly jumps to the files in the folder.

Window & Tags (Windows & Tabs)

Sublime text is a multi-window multi-label Editor: We can open multiple Sublime text windows, or you can open multiple tabs within a Sublime text window.

Window (Windows)

Use Ctrl + Shift + N Create a new window (the shortcut key again and Sogou Input Method shortcut key conflict, personal suggestions to disable all Sogou Input method shortcut keys).

When there is no label inside the window, use Ctrl + W close the window.

Label (TAB)

Use Ctrl + N the current window to create a new tab, Ctrl + W Close the current tab, and Ctrl + Shift + T restore the label you just closed.

We often open multiple windows when editing code, so it is important to split the screen. Alt + Shift + 2the left and right split screen, the Alt + Shift + 8 upper and lower sub-screen, Alt + Shift + 5 to the left and right sub-screen (that is divided into four screens).

After the split screen, use Ctrl + 数字键 The jump to the specified screen, using Ctrl + Shift + 数字键 the current screen to move to the specified screen. For example, it Ctrl + 1 jumps to the 1 screen and Ctrl + Shift + 2 moves the current screen to the 2 screen.

Fullscreen (full screen)

Sublime text has two full-screen modes: normal fullscreen and no interference fullscreen.

It is highly recommended to close the menu bar (Toggle menu) before opening full screen, otherwise the full screen effect will be greatly compromised.

F11Toggle Normal Fullscreen:

Shift + F11Toggle no interference fullscreen:

Style (styles)

Style is important for any software, as is the case with editors, especially in GUI environments. As a programmer, I want my editor to be concise and personal enough.

notepad++ Default Interface

Sublime text Default interface

So after using sublime text, I immediately removed the notepad++.

Sublime text comes in a style that is my favorite dark style (can also be turned into light), the default theme is that the Monokai Bright two are very good, but we can also do better: Next I will show how to set preferences and add custom style/theme to make Sublime Text is more stylish.

Some settings (Miscellaneous Settings)

Here are the settings I personally use.

// 设置Sans-serif(无衬线)等宽字体,以便阅读"font_face": "YaHei Consolas Hybrid","font_size": 12,// 使光标闪动更加柔和"caret_style": "phase",// 高亮当前行"highlight_line": true,// 高亮有修改的标签"highlight_modified_tabs": true,

The following effects are set:

Theme (Themes)

Sublime text has a number of third-party themes: [Https://sublime.wbond.net/browse/labels/theme], here I give a few people feel good topic:

Soda Light

Soda Dark

Nexus

Flatland

Spacegray Light

Spacegray Dark

Color (color)

Colorsublime contains a large number of sublime text color scheme, and Support Online preview, color scheme installation tutorial Here, do not repeat.

I personally use the Nexus theme and the Flatland Dark color palette, configured as follows:

"theme": "Nexus.sublime-theme","color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",

The effect is as follows:

Encoding (Coding)

The excellent editor makes coding easier, so sublime text provides a range of features to improve development efficiency.

Good practice (good practices)

Good code should be prescriptive, so Google has its code Style guideline for every major language. I myself use the following settings to normalize my code.

// 设置tab的大小为2"tab_size": 2,// 使用空格代替tab"translate_tabs_to_spaces": true,// 添加行宽标尺"rulers": [80, 100],// 显示空白字符"draw_white_space": "all",// 保存时自动去除行末空白"trim_trailing_white_space_on_save": true,// 保存时自动增加文件末尾换行"ensure_newline_at_eof_on_save": true,
Snippet (Code Snippets)

Sublime text supports snippet (code Snippet), enter the code snippet name to Tab generate the code snippet.

You can use the package control to install a third-party code snippet, or you can create your own code snippet, refer to here.

Formatting (formatting)

Sublime Text Basic manual formatting operations include: Indent to the Ctrl + [ left, Ctrl + ] indent to the right, and Ctrl + Shift + V paste the code in the current indent (very useful).

In addition to manual formatting, we can also implement automatic indentation and smart alignment by installing plugins:

    • Htmlbeautify: Formatting HTML.
    • AUTOPEP8: Format python code.
    • Alignment: Smart Alignment.
AutoComplete (Auto Completion)

Sublime Text support A certain automatic completion, according to Tab Auto-complement.

Brackets (Brackets)

When you write code, you encounter a large number of parentheses, which can be quickly toggled between the opening and closing brackets, and you Ctrl + M Ctrl + Shift + M can quickly select the content between parentheses, which is available for indented languages such as Python Ctrl + Shift + J .

In addition, I use the Brackethighlighter plugin to highlight the pairing brackets and the area of the current cursor, with the following effect:

Command line

Although the Python console is available, the sublime text console only supports single-line input, which is inconvenient, so I use sublime? REPL for some coding experiments (experiments).

Others (Miscellaneous)

Although I try to include as many sublime text practical skills as possible in this article, but are subject to space and my personal experience, this article is still missing, and you are welcome to point out the errors and omissions of this article in the comments.

Here are some features that may be useful but I seldom use them:

    • Macro: Sublime text supports recording macros, but I do not see how much use of macros in my actual work.
    • Other platforms (other platforms): This article only describes the use of sublime text on the Windows platform, but the use of sublime text on Linux and OS X is not very different from windows, except that there are differences in the shortcut keys. Please refer to Windows/linux Shortcuts and OS X shortcut keys.
    • Project (Projects): Sublime text supports simple project management, but I generally use only folders.
    • Vim mode (Vintage): Sublime text comes with vim mode.
    • Build: Through configuration, Sublime text can be built by source code.
    • Debug (Debug): By installing the plugin, Sublime text can debug the code.
List of shortcut keys (Shortcuts cheatsheet)

I have sublime text appearing in this article sorted by its type here for review.

Universal (General)
    • ↑↓←→: Move the cursor up or down, note that it is not KJHL !
    • Alt: Bring up the menu
    • Ctrl + Shift + P: Bring Up the Command board (commands Palette)
    • Ctrl + `: Bring up the console
Editor (Editing)
    • Ctrl + Enter: Adds a row below the current line and jumps to that row
    • Ctrl + Shift + Enter: Adds a row above the current row and jumps to that row
    • Ctrl + ←/→: Move word by phrase
    • Ctrl + Shift + ←/→Make word-wise selection
    • Ctrl + ↑/↓Move the current display area
    • Ctrl + Shift + ↑/↓Moving forward
Select (Selecting)
    • Ctrl + D: Select the word where the current cursor is located and highlight all occurrences of the word, Ctrl + D select the next position where the word appears, and in the process of multiple selection, use Ctrl + K to skip, use Ctrl + U to rollback, use to Esc exit multiple edits
    • Ctrl + Shift + L: Breaks the current selected area
    • Ctrl + J: Merges the currently selected area into one row
    • Ctrl + M: Toggle between start and end brackets
    • Ctrl + Shift + M: Quickly select the content between parentheses
    • Ctrl + Shift + J: Quickly select the same indent content
    • Ctrl + Shift + Space: Quickly select the contents of the current scope (scope)
Find & Replace (finding&replacing)
    • F3: Jumps to the next position of the current keyword
    • Shift + F3: Jumps to a position on the current keyword
    • Alt + F3: Selects all locations where the current keyword appears
    • Ctrl + F/H: Perform standard find/replace, after:

      • Alt + C: Toggle Case Sensitive (case-sensitive) mode
      • Alt + W: Toggle Whole Word matching (Whole matching) mode
      • Alt + R: Toggle regular Match (Regex matching) mode
      • Ctrl + Shift + H: Replace current keyword
      • Ctrl + Alt + Enter: Replace all keyword matches
    • Ctrl + Shift + F: Multi-File Search & Replace

Jump (jumping)
    • Ctrl + P: Jump to the specified file and enter a filename to:

      • @Symbol Jump: Enter @symbol symbol the location where the symbol is located
      • #Keyword Jump: Enter #keyword the location to jump to keyword
      • :Line number jump: input :12 jumps to the 12th line of the file.
    • Ctrl + R: Jumps to the specified symbol
    • Ctrl + G: Jumps to the specified line number

Window (Windows)
    • Ctrl + Shift + N: Create a new window
    • Ctrl + N: Creates a new label in the current window
    • Ctrl + W: Closes the current tab and closes the window when no label is in the window
    • Ctrl + Shift + T: Restores the label just closed
Screens (screen)
    • F11: Toggle Normal Fullscreen
    • Shift + F11: Toggle No interference fullscreen
    • Alt + Shift + 2: The left and right split screen
    • Alt + Shift + 8: To split the screen up and down
    • Alt + Shift + 5: Next to left and right split screen
    • After the split screen, use Ctrl + 数字键 jump to the specified screen, using Ctrl + Shift + 数字键 the current screen to move to the specified screen
Extended reading (further Reading) books (Books)
    • Mastering Sublime Text: The only book I have read about Sublime text, the plugin in the book is very practical, but the editing techniques are not fully introduced.
    • Instant Sublime Text Starter: Another book about Sublime text that I haven't read.
Link (links)
    • Official Document: http://www.sublimetext.com/docs/3/
    • Official Forum: http://www.sublimetext.com/forum/
    • Stack Overflow's sublime text channel:
    • Http://stackoverflow.com/questions/tagged/sublimetext
    • Http://stackoverflow.com/questions/tagged/sublimetext2
    • Http://stackoverflow.com/questions/tagged/sublimetext3
    • Unofficial document: http://sublime-text-unofficial-documentation.readthedocs.org/is even more comprehensive than official documents!
    • Package control:https://sublime.wbond.net/A large number of sublime text plugins and themes.
Video (Videos)
    • Getting Started with Sublimetext:https://www.youtube.com/watch?v=04gkitirlq8
    • Sublime Text Pefect workflow:https://www.youtube.com/watch?v=bpep0epioem&list= pluwqxbvf3olplsnfvo06gbrkceb5o7k0g

Reference: http://www.cnblogs.com/figure9/p/sublime-text-complete-guide.html

Sublime Text 3 using

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: info-contact@alibabacloud.com 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.