Sublime Text3 configuration tutorial

Time:2020-4-6

The portable version of sublime Text3 has been built on WIN platform. However, now, Ubuntu can’t be used synchronously. Take a rest at home in winter vacation, and sort out the installation process

Install sublime

Select the appropriate version to install on the sublime text website.

After the Ubuntu installation is complete, you can/usr/share/applicationsFind the sublime text express mode in the folder, start and fix it in the startup bar. (or try the commandsubStart up).

Install version build mobile version

Don’t worry about opening sublime text for this installation. For the convenience of later installation, it is decided not to use the default packages installation path of the system
Folder% appdata% or C: usersadministratorappdataroamingdata please enter% appdata% in the address bar first and then delete the sublime text 3 folder under this directory.

Create a new folder / data in the installation directory of sublime Text3, and open the sublime text program after the folder is created. We found that packages are installed in the currently created folder (my path is D: \ program files \ sublime text 2 \ data). Later, we installed all the other necessary plug-ins. Let's back up the sublime text 2 folder, so that we can quickly deploy our sublime text environment wherever we go in the future without any step-by-step reinstallation.

Data folder (case sensitive)

https://segmentfault.com/a/11…

Install plug-ins

Install plug-in managerpackage control

Ctrl + ~Open the console, copy and paste the following code to the console, enter and wait for the installation to complete.
If you install sublime text2, you can go to package control to find the 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( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

Install additional plug-ins

Then use the shortcut keyCtrl+Shift+PInputpciIn general, the first item ispackage control : install package。 Next, install and configure some common extensions:

  • emmet

It’s a must-have artifact at the front. Emmet document front-end development required! Emmet user manual

  • sidebarenhancement

Sidebar enhancements, sublime text 3 extension sidebar enhancements tutorial – quick preview of web pages with browser

  • JavaScript Completions

JS syntax auto completion

  • AdvancedNewFile

Quickly create new files and customize file formats. Set the following shortcut keys:ctrl+nWill start the extension, directly input the file name + format, refreshing!

[
    { "keys": ["ctrl+n"],
            "command": "advanced_new_file_new"
        }
]
  • Color Highlighter

When the front end edits the color, the plug-in displays the actual color of the corresponding color code.

  • AutoFileName

Autocomplete file (directory) name

  • BracketHighlighter

Highlight the matching brackets and the area of the current cursor. Configuration method of brackethighlighter in sublime Text3

  • Docblokr

Code comment, directly or select the code to be commented, shortcut keyctrl+/。 This plug-in can generate JS, PHP and other language function comments very well. Just input / * * * on the function, and then press tab to automatically generate comments and enhance JS comments.

  • SublimeLinter

This is for code checking when writing code. When you write a python program, it will also help you check whether the code meets the requirements of pep8. If there is a problem, there will be a white box in the code. When you click, the status bar at the bottom will prompt you what the problem is. Sublimelinter is a code verification plug-in. It can help you find errors or write irregular code. It supports C / C + +, coffeespcript, CSS, GIT commit messages, HAML, HTML, Java, JavaScript, Lua, objective-j, Perl, PHP, puppet, python, ruby and XML. Before using sublimelinter, you need to install the corresponding program. See readme for details. If you want to verify JavaScript or CSS, you also need to install node.js. Sublimelinter runs in background mode by default, and is verified immediately when the user enters. If you want to run sublimetext more smoothly, you can change it to load save mode or save only mode, and verify when reading and saving or only when saving. Open sublimelinter’s profile: menuPreferences -> Package Settings -> SublimeLinter -> Settings - User, add “sublimelinter”: “load save” or “sublimelinter”: “save only”

  • Anaconda

AnacondaPyflakes, pep8 and McCabe are integrated as plug-ins. After installing anaconda, you can complete a good Python development environment through configuration.
How to remove the box when editing py file
You can set shutdown in sublime > Preferences > package Settings > Anaconda > Settings user:
{"anaconda_linting": false}

Autocompletion
Auto complete. This option is on by default and provides multiple configuration options.
Code linting
Use pylint or pyflakes that support the pep8 standard. Because I personally use another linking tool, I will disable it completely in Anaconda's configuration file anaconda.sublime-settings. **The operation is as follows: Sublime > Preferences > package Settings > Anaconda > settings – user: {"Anaconda {linking": false}**
McCabe code complexity checker
If you are not familiar with the software complexity checking tool, please be sure to browse the above link first.
Goto Definitions
Be able to find and display the definition of any variable, function or class in your whole project.
Find Usage
It can quickly find out where a variable, function or class is used in a specific file.
Show Documentation
The ability to display a descriptive string of a function or class (with a string defined, of course)
  • ConvertToUTF8

GBK code is compatible. Although Chinese can be input and displayed normally in ST3, ST3 will display garbled code when opening the file containing Chinese characters. To solve the problem of Chinese scrambling, you need to install the converttoutf8 plug-in. OS X or Linux also requires plug-insCodecs33

  • Terminal

This is used to open the terminal in the current file location. Reference resources

  • status bar time

Display time

  • themr

The management of theme package does not need one item configuration to switch theme after installation. Using shortcut keysctrl+f5switchthemeAnd thenPreferencesSet favorite incolor scheme。 Otherwise, the style of the sidebar / tab bar will not change after the theme of the editing area is switched, which needs to be set in the settings.

  • Sublime​Code​Intel

Support all code languages supported by komode editor, such as: Javascript, Mason, XBL, XUL, rhtml, SCSS, python, HTML, ruby, python 3, XML, sass, XSLT, Django, HTML5, Perl, CSS, twig, less, Smarty, node.js, TCL, templatetoolkit, PHP, etc.

  • Alignment

Make smart alignment. But the default shortcut isctrl+alt+a, which conflicts with the shortcut key of a famous im screenshot in China. I changed it toalt+shift+f

  • AutoPEP8

Format Python code. After installation, add the following configuration to automatically format when saving files:

{
    "format_on_save": true,
}
  • IMESupport

Can’t Chinese input follow the cursor? Try imesupport! Currently only windows is supported

  • Markdownediting and markdownpreview

After installation, when writing markdown (the syntax in the lower right corner is markdown), you can pressctrl+b, HTML will be generated directly and displayed in the browser.

  • KeymapManager

Add the function of detecting shortcut key conflict. Refer to keymapmanager to add the function of detecting shortcut key conflict

  • Boxy Theme

After installation, you can get several themes. With the a file icon extension, the file will also have icons

Configuration (settings)

Sublime text does not have a special configuration interface. Instead, sublime text uses JSON configuration files. You can refer toPreferences->Settings-UserNow my settings are as follows:

{
    "bold_folder_labels": true,
    "caret_style": "phase",
    "color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
    "draw_white_space": "all",
    "ensure_newline_at_eof_on_save": true,
    "font_face": "microsoft yahei",
    "font_size": 12,
    "highlight_line": true,
    "highlight_modified_tabs": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "open_files_in_new_window": false,
    "rulers":
    [
        80,
        100
    ],
    "save_on_focus_lost": true,
    "show_encoding": true,
    "show_full_path": true,
    "spell_check": false,
    "tab_size": 4,
    "theme": "Material-Theme-Darker.sublime-theme",
    "translate_tabs_to_spaces": true,
    "trim_trailing_white_space_on_save": true,
    "word_wrap": false
}

Set shortcut key

preferences->key bindings-user

[

    //chrome
    { "keys": ["f1"], "command": "side_bar_files_open_with",
            "args": {
                "paths": [],
                "application": "C:\Program Files\Google\Chrome\Application\chrome.exe",
                "extensions":".*"
            }
     },
    { "keys": ["ctrl+n"],
            "command": "advanced_new_file_new"
        }
]

Common shortcut keys

Alt + shift + 1Default 1 screen
Alt + shift + 2Left and right 2 screens
Alt + shift + 8Two screens up and down

Ctrl + /Notes single line
Ctrl + shift + /Notes for multiple rows

Ctrl + k + uConvert to uppercase
Ctrl + k + lConvert to lowercase

Ctrl + EnterInsert a row down
Ctrl + shift + EnterInsert a row up
ctrl+shift+DCopy one line to the next

Ctrl + shift + [Paragraph folding
Ctrl + shift + ]Paragraph opening

Ctrl + DDownward multiple selection
Crtl + k + BTurn sidebar on / off
Ctrl + RSearch function

Ctrl+LSelect row, repeat to add and select next row in turn
Ctrl+Shift+LSelect multiple rows

Ctrl+GJump to line
Ctrl+XDelete current row

Ctrl+FFind content
Ctrl+Shift+FFind and replace
Ctrl+Hreplace

F11Full screen
Shift+F11Full screen undisturbed mode, only edit the current file

Alt+ digitSwitch to open the nth file
Ctrl + p

1. Enter file name, jump
2. input: line number, jump to the specified line number, for example: 55
3. Take all identifications of the current document

FAQ

Sublime command window cannot display Chinese

The default compiler can directly press Ctrl + B to compile and run python, and output the results in the console. The beauty is that it can’t output Chinese, so you need to manually configure it.
In sublime text 3, click Tools – > build system – > new build system, paste the code below and save it as python.sublime-build. Restart sublime.

{  
    "cmd": ["python","-u","$file"],  
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",  
    "selector": "source.python",  
    "encoding": "cp936"  
}  

Invalid open in browser

The latest sublime Text3 already has this function by default. At first, I modified the default opening method of HTML to editor, so it doesn’t work when I use this function. Later, I changed it to chrome to open by default, and then it’s OK to use this function again
https://forum.freecodecamp.or…

Reference resources

Reference article is also the essence!!!

  • Sublime text guide – Lu
  • Developing python with sublime text 3
  • Self cultivation of sublime Text3 of a front-end program ape
  • jikeytang/sublime-text-github
  • Sublime text 3 best features, plug-ins and settings
  • Sublime text plug-in recommendations
  • Sublime text 3 best features, plug-ins and settings
  • Sublime Text3 use summary – add to win right click Use sublime text to open
  • Sublime text 3 novice toss
  • Sublime text 2 configuration for Python programmers – terminal
  • Sublime Text3 – Utility settings
  • How to build Python ide with sublime text 3?

Recommended Today

PHP Basics – String Array Operations

In our daily work, we often need to deal with some strings or arrays. Today, we have time to sort them out String operation <?php //String truncation $str = ‘Hello World!’ Substr ($STR, 0,5); // return ‘hello’ //Chinese string truncation $STR = ‘Hello, Shenzhen’; $result = mb_ Substr ($STR, 0,2); // Hello //First occurrence of […]