I. code snippets
Developers often do repetitive work.
The addition, deletion, modification, and query operations for different data tables are similar and repeated. I haven't written any program for a long time. I used my 11 holiday to read books and write programs at home.
I have been very fond of using Sublime Text recently and found that its code snippet management function is good. As long as you enter a pre-defined phrase, the code snippets of a large segment can be automatically filled in. You can also define variables.
Such as PHP code. You can use $ {0} to define each parameter, and so on. If you want to retain the $ character in the code snippet, you only need to add the \ character before the $ character. For example, \ $ data
The procedure is as follows:
1. Select Tools> New Snippet.
This creates an empty code snippet template. As follows:
<! [CDATA [<snippet> <content> <! [CDATA [Hello, $ {1: this} is a $ {2: snippet}.]> </content> <! -- Optional: Set a tabTrigger to define how to trigger the snippet --> <! -- <TabTrigger> hello </tabTrigger> --> <! -- Optional: Set a scope to limit where the snippet will trigger --> <! -- <Scope> source. python </scope> --> </snippet>
In[ ]
Put your code in the middle, and use $ {} to replace any keyword. The numbers in the middle are in the order of the cursor, and switch by the TAB key.
TabTrigger: Enter keywords in the editor, and press the TAB key.
Scope: where the class source program plays a role, of course, can not be set
Description: The prompt description.
Save it. Remember to save it as. sublime-snippet extension. If an existing package is opened, you can use Preferences-"Browse Packages to locate it in user defined. Please note that I am using a MAC version. I don't know where it is in windows, and I have never used it in windows.
Below is a small template I wrote:
<Snippet> <content> <! [CDATA [/*** Delete * @ param string \ $ {1} ID of the data record * @ param string \ $ {2: tabelname} data table name * @ return void **/public function del () {\\ {1} = trim (\$ _ GET ['$ {1}']); if (empty (\ $ {1}) {\ $ this-> error ('this record does not exist! ') ;}\$ Result = M (' $ {2: tabelname }') -> where (array ('$ {1}' =>\$ $ {1})-> delete (); \ $ this-> message (\ $ result, '_ URL _/Index',' deleted successfully! ',' Deletion failed! ') ;}]]> </Content> <! -- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger> tpdel </tabTrigger> <! -- Optional: Set a scope to limit where the snippet will trigger --> <! -- <Scope> source. python </scope> --> <description> ThinkPHP-del () delete a data method </description> </snippet>
Sublime Text 3 is quite handy, but debugging is not convenient when writing PHP programs. It is still useful to write PHP programs using PhpStorm. I use PhpStorm6. After the above situation, I want to see if PhpStorm can do the same. After research, we found that this development tool is also good. Tip: The command + J prompt is displayed in the editor. In windows, press ctrl + J.
Usage:
There is a Live Templates setting item in Preferences. There are many examples in it. You can try it. The template editing method is similar to that of Sublime Text. Only \ is not needed here.
If you want to retain the $ character in the template, you only need to enter $. You can also set the default value of the parameter and format it automatically after the output.
The development efficiency will be greatly improved by making good use of development tools.
Source: http://blog.segmentfault.com/microrain/1190000000316709>
2. Install plug-ins online
Ctrl +'Or View> Show Console
Sublime text 3
Import urllib. request, OS, hashlib; h = '7183a2d3e96f11eeadd761d777e62404e330c659d4bb41d3bdf022e94cab3cd0 '; pf = 'package Control. sublime-package '; ipp = sublime. installed_packages_path (); urllib. request. install_opener (urllib. request. build_opener (urllib. request. proxyHandler (); by = urllib. request. urlopen ('HTTP: // sublime.wbond.net/'+ pf. replace ('', '% 20 ')). read (); dh = hashlib. sha256 (). hexdi Gest (); print ('error validating download (got % s instead of % s), please try manual install '% (dh, h) if dh! = H else open (OS. path. join (ipp, pf), 'wb'). write ()
Sublime text 2
1 |
import urllib2,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404e330c659d4bb41d3bdf022e94cab3cd0' ; 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()) ); by = urllib2.urlopen( 'http://sublime.wbond.net/' + pf.replace( ' ' , '%20' )).read(); dh = hashlib.sha256(by).hexdigest(); open ( os.path.join( ipp, pf), 'wb' ).write(by) if dh = = h else None ; print ( 'Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh ! = h else 'Please restart Sublime Text to finish installation' ) |
Source: http://www.cnblogs.com/bugs/p/3533202.html>
3. Set your own style
Sublime Text 3 configuration explanation (default)
{
// Set the topic File
"Color_scheme": "Packages/Color Scheme-Default/Monokai. tmTheme ",
// Set the font and size
"Font_face": "Consolas ",
"Font_size": 12,
// Font options: no_bold does not show bold characters, no_italic does not show italic, no_antialias and no_antialias disable anti-sawtooth
// Subpixel_antialias and no_round are unique to OS X.
"Font_options": [],
// Double-click the text to select the current content. If the following characters appear, the content will be truncated.
"Word_separators": "./\ () \" '-:,.; <> ~! @ # $ % ^ & * | + = [] {} '~? ",
// Whether the row number is displayed
"Line_numbers": true,
// Whether the row number sidebar is displayed
"Gutter": true,
// Spacing between the sidebar and text of the row number
"Margin": 4,
// Whether the code folding button is displayed
"Fold_buttons": true,
// The Code folding button is always displayed no matter the mouse is not in the row number sidebar
"Fade_fold_buttons": true,
// The vertical ruler is displayed in the column, and a number is filled in brackets. The width is calculated by character.
"Rulers": [],
// Check whether spelling is enabled
"Spell_check": false,
// Tab key Tab width
"Tab_size": 4,
// If it is set to true, indent and use spaces to replace the Tab key
"Translate_tabs_to_spaces": false,
// Otherwise, a single space is used.
"Use_tab_stops": true,
"Detect_indentation": true,
// When you press enter, it is automatically aligned with the tab.
"Auto_indent": true,
// For C Language
"Smart_indent": false,
// Do I need to enable auto_indent and insert a space when the parentheses are indented for the first time? (No results tested ...)
"Indent_to_bracket": true,
// Whether the alignment white line is automatically filled by carriage return or tab
"Trim_automatic_white_space": true,
// Whether to automatically wrap the line. If auto is selected, double quotation marks must be added.
"Word_wrap": false,
// Set the width of the text area in the window
"Wrap_width": 0,
// Prevent line breaks from being indented to the same level
"Indent_subsequent_lines": true,
// If not defined, the file is displayed in the center (for example, the new file)
"Draw_centered": false,
// Automatically match quotation marks, Parentheses, and so on
"Auto_match_enabled": true,
// Path of the spelling check word list
"Dictionary": "Packages/Language-English/en_US.dic ",
// Check whether the border is added to the visible area of the Code map. You can add the minimapBorder key to the border color scheme.
"Draw_minimap_border": false,
// Highlight the row where the current cursor is located
"Highlight_line": false,
// Set the cursor flashing mode
"Caret_style": "smooth ",
// Whether to display the parentheses of the current cursor and the closing mark of the Code header.
"Match_brackets": true,
// If it is set to false, match_brackets takes effect only when the cursor is at either side of the brackets or the end and end of the mark.
"Match_brackets_content": true,
// Whether to highlight parentheses. The value of match_brackets is true.
"Match_brackets_square": false,
// Whether to highlight the braces. The value of match_brackets is true.
"Match_brackets_braces": false,
// Whether to highlight the angle brackets. The value of match_brackets is true.
"Match_brackets_angle": false,
// Highlight the two ends of the tag where the cursor is located under html and xml, affecting HTML, XML, CSS, etc.
"Match_tags": true,
// The full text is highlighted with the same characters as the currently selected characters
"Match_selection": true,
// Set the spacing between each row and the top, in pixels. The effect is equivalent to the line spacing.
"Line_padding_top": 1,
// Set the spacing from each row to the bottom in pixels. The effect is equivalent to the line spacing.
"Line_padding_bottom": 1,
// When it is set to false, when it is scrolled to the bottom of the text, there is no buffer
"Scroll_past_end": true,
// Control what happens when going up or down to the first or last line
"Move_to_limit_on_up_down": false,
// When you press space or tab, a white point (a space or a point) or a White horizontal line (the width of the tab set by tab_size) will be generated, which can be seen only when selected.
// When it is set to none, these points and lines are not displayed under any circumstances
// When it is set to selection, only the points and lines in the selected status are displayed.
// If it is set to all, it is always displayed
"Draw_white_space": "selection ",
// Check whether the alignment of the tab is displayed in white line. You can set the color in the topic file (guide, activeGuide, stackGuide)
"Draw_indent_guides": true,
// White line alignment of the tab, draw_normal is always displayed, and draw_active is only the code control domain where the current cursor is located
"Indent_guide_options": ["draw_normal"],
// If this parameter is set to true, extra spaces are deleted when each row ends.
"Trim_trailing_white_space_on_save": false,
// If the value is true, the time mark for saving the file will be changed to the next line at the end of the file
"Ensure_newline_at_eof_on_save": false,
// Switch to another file tag or click another non-software area to automatically save the file
"Save_on_focus_lost": false,
// When encoding is not automatically detected when encoding, it will automatically detect ASCII, UTF-8 and UTF-16
"Fallback_encoding": "Western (Windows 1252 )",
// Default encoding format
"Default_encoding": "UTF-8 ″,
// Files containing NULL bytes are opened in hexadecimal format by default.
"Enable_hexadecimal_encoding": true,
// What character is used as the terminator when each row ends?
"Default_line_ending": "system ",
// When it is set to enabled, a Tab is inserted between strings by pressing Tab.
// If it is set to true, the code will be automatically matched based on the environment before and after the Tab.
"Tab_completion": true,
// Code prompt
"Auto_complete": true,
// Code prompt size limit
"Auto_complete_size_limit": 4194304,
// Code prompts delayed display
"Auto_complete_delay": 50,
// Control scope of code prompts
"Auto_complete_selector": "source-comment ",
// Other situations that trigger code prompts
"Auto_complete_triggers": [{"selector": "text.html", "characters": "<"}],
// If it is set to false, press ENTER or click the prompt code to output the Code. However, if it is set to true, the line feed is not output but directly generated.
"Auto_complete_commit_on_tab": false,
// If it is set to false, Shift + tab always inserts a tab
"Shift_tab_unindent": true,
// Press Ctrl + f to automatically copy the selected text to the search panel text box.
"Find_selected_text": true,
// Topic of the Data \ Packages \ Theme-Default \ Default. sublime-theme Control Software
"Theme": "Default. sublime-theme ",
// Scroll speed
"Scroll_speed": 1.0,
// Animation of the left sidebar folder
"Tree_animation_enabled": true,
// Close the tab
"Show_tab_close_buttons": true,
// For OS X
"Use_simple_full_screen": false,
// Horizontal and vertical scroll bars: system and disabled are the default display modes, and enabled is the Auto Hide display mode.
"Overlay_scroll_bars": "system ",
// Popular features! Exit directly instead of saving the file.
// When the software is opened next time, the file remains in the state before exiting, And the content not saved can be found, but it is not actually written in the original file
"Hot_exit": true,
// The software uses the final setting to open the file. If hot_exit is set to true, it will not work.
"Remember_open_files": true,
// For OS X
"Open_files_in_new_window": true,
// For OS X
"Close_windows_when_empty": true,
// Which files will be displayed on the sidebar
"Folder_exclude_patterns": [". svn", ". git", ". hg", "CVS"],
"File_exclude_patterns ":["*. pyc ","*. pyo ","*. exe ","*. dll ","*. obj ","*. o ","*. a ","*. lib ","*. so ","*. dylib ","*. ncb ","*. sdf ","*. suo ","*. pdb ","*. idb ",". DS_Store ","*. class ","*. psd ","*. db "],
// Goto Anything or Find in Files
"Binary_file_patterns ":["*. jpg ","*. jpeg ","*. png ","*. gif ","*. ttf ","*. tga ","*. dds ","*. ico ","*. eot ","*. pdf ","*. swf ","*. jar ","*. zip "],
// Delete the plug-in you want to ignore. Restart the plug-in and remove the Vinage to enable the vim mode.
"Ignored_packages": ["Vintage"]
}
My configurations:
{
"Default_encoding": "UTF-8 ″,
"Auto_complete_commit_on_tab": false,
"Auto_complete_delay": 0,
"Auto_complete_with_fields": true,
"Auto_indent": true,
"Auto_match_enabled": true,
"Bold_folder_labels": true,
"Caret_style": "wide ",
"Color_scheme": "Packages/Color Scheme-Default/Monokai Bright. tmTheme ",
"Fade_fold_buttons": false,
"Fold_buttons": true,
"Font_face": "Consolas ",
"Font_options": [],
"Font_size": 13,
"Highlight_line": true,
"Hot_exit": false,
"Ignored_packages": [],
"Match_brackets_angle": true,
"Match_brackets_content": true,
"Match_tags": true,
"Remember_open_files": false,
"Smart_indent": true,
"Tab_size": 4,
"Word_wrap": "false"
}
Shortcut Key:
[
{"Keys": ["ctrl + ["], "command": "exit_insert_mode "},
{"Keys": ["ctrl + h"], "command": "left_delete "},
{"Keys": ["alt + h"], "command": "move", "args": {"by": "characters", "forward ": false }},
{"Keys": ["alt + l"], "command": "move", "args": {"by": "characters", "forward ": true }},
{"Keys": ["alt + k"], "command": "move", "args": {"by": "lines", "forward ": false }},
{"Keys": ["alt + j"], "command": "move", "args": {"by": "lines", "forward ": true }},
{"Keys": ["ctrl + j"], "command": "insert", "args": {"characters": "\ n "}},
{"Keys": ["ctrl + I"], "command": "auto_complete "},
{"Keys": ["ctrl + I"], "command": "replace_completion_with_auto_complete", "context ":
[
{"Key": "last_command", "operator": "equal", "operand": "insert_best_completion "},
{"Key": "auto_complete_visible", "operator": "equal", "operand": false },
{"Key": "setting. tab_completion", "operator": "equal", "operand": true}
]
}
{"Keys": ["ctrl + d"], "command": "right_delete "},
{"Keys": ["alt + s"], "command": "save "},
]
Source: http://blog.csdn.net/hexrain/article/details/13997565>
Iv. Shortcut Keys
Ctrl + D (press the shortcut key repeatedly to continue and select the next same text for simultaneous editing)Ctrl + G jump to the corresponding row
Ctrl + J merge rows (multiple rows to be merged have been selected)
Ctrl + L select the entire line (Press and hold-continue to select downstream)
Ctrl + M move the cursor to the start or end position in parentheses
Ctrl + T word Interchange
Ctrl + U soft undo
Ctrl + P search for files and quick searches in the current project; enter @ to search for the main file title/function; or enter: jump to a line of the file;
Ctrl + R quickly list/jump to a function
Ctrl + K Backspace Delete from cursor to first line
Ctrl + K + B enable/disable sidebar
Ctrl + KK Delete from cursor to end of line
Ctrl + K + T fold attribute
Ctrl + K + U to uppercase
Ctrl + K + L to lowercase
Ctrl + K + 0 show all
Ctrl + Enter insert row (line feed)
Ctrl + Tab switch in the current window
Ctrl + Shift + A select the cursor position parent tag
Ctrl + Shift + D copy the entire row where the cursor is located and insert it before this row
Ctrl + shift + F search in folders. Unlike the normal Editor, sublime allows you to add Multiple folders for search.
Ctrl + Shift + K Delete the entire row
Ctrl + Shift + L select multiple rows with the mouse (press the shortcut key) to edit these rows at the same time
Ctrl + Shift + M select the content in the brackets (Press and hold-continue to select the parent bracket)
Ctrl + Shift + P open the Command Panel
Ctrl + Shift +/comment on selected content
Ctrl + Shift + continue: This line of code can be moved and exchanged with the upstream
Ctrl + Shift + continue: This line of code can be moved and exchanged with the downstream code.
Ctrl + Shift + [collapse code
Ctrl + Shift +] Show Code
Ctrl + Shift + Enter insert row before cursor
Ctrl + PageDown, Ctrl + PageUp switch files in the order they are enabled
Ctrl + Z undo
Ctrl + Y resume undo
Ctrl + F2 set/cancel bookmarks
Ctrl +/comment out the entire line (if the selected content is used, the effect is the same as that of "Ctrl + Shift +)
Ctrl + left mouse button can select multiple texts to edit at the same time
Shift + right-click (or use the middle mouse button) to select vertical lines
Shift + F2 bookmarks
Shift + Tab remove indentation
Alt + Shift + 1 (non-keypad) window split, Restore Default 1 screen
Alt + Shift + 2 left/right split-2 columns
Alt + Shift + 3 left/right split-3 columns
Alt + Shift + 4 left/right split-4 columns
Alt + Shift + 5 equals 4 screens
Alt + Shift + 8 Vertical Split-2 Screen
Alt + Shift + 9 Vertical Split-3 Screen
Ctrl + Shift + split sequence number: distribute the current focus page to the split sequence number page
Alt +. Close the current tag
Alt + F3 select text press the shortcut key to select all the same text for simultaneous editing
Tab indent automatically completed
Next bookmarks on F2
F6 check syntax error
Sort F9 rows by a-z)
F11 full screen mode