sublimephp格式化,sublime代碼格式化

本文目錄一覽:

sublime thinkphp怎麼安裝

其實在sublime中已經自建了格式化按鈕:

Edit – Line – Reindent

只是sublime並沒有給他賦予快捷鍵,所以只需加上快捷鍵即可

Preference – Key Bindings -user

中 括號內添加(比如添加:ctrl + alt + f)

{ “keys”: [“ctrl+alt+f”], “command”: “reindent” }

1、打開 Sublime Text 2,按下 Control + ` 調出 Console,通常這個快捷鍵會與PC上的其它軟件起衝突,需要修改其它軟件的這個快捷鍵。

2、將以下代碼粘貼進命令行中並回車:

import urllib2,os;pf=’Package Control.sublime-package’;ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),’wb’).write(urllib2.urlopen(”+pf.replace(‘ ‘,’%20’)).read())

3、重啟 Sublime Text 2,如果在 Preferences – Package Settings中見到Package Control這一項,就說明安裝成功了。

按ctrl+shift+p 輸入install

回車,等待響應,輸入「format」,就可以顯示很多格式化軟件

根據自己的使用選擇喜歡的,你就直接輸入thinkphp就出現了

然後安裝即可

sublimetext自帶格式化代碼功能 怎麼用

安裝格式化插件: 1.按Ctrl+Shift+P調出命令面板 2.輸入 install 調出 Package Control: Install Package 選項,按下回車,底部框接着輸入「Tag」,再次按回車等待安裝完成並重啟。 使用: 選中一段html代碼,按Ctrl+Alt+F即可。

Sublime Text,php代碼格式化插件codeformatter 設置PHP代碼格式時報錯 怎麼處理

{

“codeformatter_debug”: false,

“codeformatter_php_options”:

{

“syntaxes”: “php”, // Syntax names which must process PHP formatter

“php_path”: “這裡改成你php的路徑”, // Path for PHP executable, e.g. “/usr/lib/php” or “C:/Program Files/PHP/php.exe”. If empty, uses command “php” from system environments

“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”

“php55_compat”: false, // PHP 5.5 compatible mode

“psr1”: false, // Activate PSR1 style

“psr1_naming”: false, // Activate PSR1 style – Section 3 and 4.3 – Class and method names case

“psr2”: true, // Activate PSR2 style

“indent_with_space”: 4, // Use spaces instead of tabs for indentation

“enable_auto_align”: true, // Enable auto align of = and =

“visibility_order”: true, // Fixes visibility order for method in classes – PSR-2 4.2

“smart_linebreak_after_curly”: true, // Convert multistatement blocks into multiline blocks

// Enable specific transformations. Example: [“ConvertOpenTagWithEcho”, “PrettyPrintDocBlocks”]

// You can list all available transformations from command palette: CodeFormatter: Show PHP Transformations

“passes”: [],

// Disable specific transformations

“excludes”: []

},

“codeformatter_js_options”:

{

“syntaxes”: “javascript,json”, // Syntax names which must process JS formatter

“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”

“indent_size”: 4, // indentation size

“indent_char”: ” “, // Indent character

“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)

“eol”: “\n”, // EOL symbol

“preserve_newlines”: false, // whether existing line breaks should be preserved,

“max_preserve_newlines”: 10, // maximum number of line breaks to be preserved in one chunk

“space_in_paren”: false, // Add padding spaces within paren, ie. f( a, b )

“space_in_empty_paren”: false, // Add padding spaces within paren if parent empty, ie. f( )

“e4x”: false, // Pass E4X xml literals through untouched

“jslint_happy”: false, // if true, then jslint-stricter mode is enforced. Example function () vs function()

“space_after_anon_function”: false, // Space after anonimouse functions

“brace_style”: “collapse”, // “collapse” | “expand” | “end-expand”. put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.

“keep_array_indentation”: false, // keep array indentation.

“keep_function_indentation”: false, // keep function indentation.

“eval_code”: false, // eval code

“unescape_strings”: false, // Decode printable characters encoded in xNN notation

“wrap_line_length”: 0, // Wrap lines at next opportunity after N characters

“unindent_chained_methods”: false, // Unindent chained method calls

“break_chained_methods”: false, // Break chained method calls across subsequent lines

“end_with_newline”: false, // Add new line at end of file

“comma_first”: false, // Add comma first

“operator_position”: “before-newline” // Operator position: before-newline, after-newline, preserve-newline

},

“codeformatter_css_options”:

{

“syntaxes”: “css,less”, // Syntax names which must process CSS formatter

“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”

“indent_size”: 4, // Indentation size

“indent_char”: ” “, // Indentation character

“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)

“selector_separator_newline”: false, // Add new lines after selector separators

“end_with_newline”: false, // Add new line of end in file

“newline_between_rules”: false, // Add new line between rules

“space_around_combinator”: false, // Space around combinator

“eol”: “\n” // EOL symbol

},

“codeformatter_scss_options”:

{

“syntaxes”: “scss,sass”, // Indentation size

“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”

“indent_size”: 4, // Indentation size

“indent_char”: ” “, // Indentation character

“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)

“selector_separator_newline”: false, // Add new lines after selector separators

“end_with_newline”: false, // Add new line of end in file

“newline_between_rules”: false, // Add new line between rules

“space_around_combinator”: false, // Space around combinator

“eol”: “\n” // EOL symbol

},

“codeformatter_html_options”:

{

“syntaxes”: “html,blade,asp,xml”, // Syntax names which must process HTML formatter

“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”

“formatter_version”: “bs4”, // Which formatter to use. Current options are “bs4” and “regexp”. If an error occurs while loading the bs4 formatter, the regexp formatter will automatically be used

“indent_size”: 4, // indentation size

“indent_char”: ” “, // Indentation character

“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)

“exception_on_tag_mismatch”: false, // If the last closing tag is not at the same indentation level as the first opening tag, there’s probably a tag mismatch in the file

“expand_javascript”: false, // (Under construction) Expand JavaScript inside of script tags (also affects CSS purely by coincidence)

“expand_tags”: false, // Expand tag attributes onto new lines

“minimum_attribute_count”: 2, // Minimum number of attributes needed before tag attributes are expanded to new lines

“first_attribute_on_new_line”: false, // Put all attributes on separate lines from the tag (only uses 1 indentation unit as opposed to lining all attributes up with the first)

“reduce_empty_tags”: false, // Put closing tags on same line as opening tag if there is no content between them

“reduce_whole_word_tags”: false, // Put closing tags on same line as opening tag if there is whole word between them

“custom_singletons”: “” // Custom singleton tags for various template languages outside of the HTML5 spec

},

“codeformatter_python_options”:

{

“syntaxes”: “python”, // Syntax names which must process Python formatter

“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”

“indent_size”: 1, // indentation size

“indent_with_tabs”: true, // Indent with tabs or spaces

“max_char”: 80, // Width of output lines in characters.

“assignment”: ” = “, // This is how the assignment operator is to appear.

“function_param_assignment”: “=”, // This is how function-parameter assignment should appear.

“function_param_sep”: “, “, // This is how function parameters are separated.

“list_sep”: “, “, // This is how list items are separated.

“subscript_sep”: “=”, // This is how subscripts are separated.

“dict_colon”: “: “, // This separates dictionary keys from values.

“slice_colon”: “:”, // this separates the start:end indices of slices.

“comment_prefix”: “# “, // This is the sentinel that marks the beginning of a commentary string.

“shebang”: “#!/usr/bin/env python”, // Hashbang, a line-one comment naming the Python interpreter to Unix shells.

“boilerplate”: “”, // Standard code block (if any). This is inserted after the module doc string on output.

“blank_line”: “”, // This is how a blank line is to appear (up to the newline character).

“keep_blank_lines”: true, // If true, preserve one blank where blank(s) are encountered.

“add_blank_lines_around_comments”: true, // If true, set off comment blocks with blanks.

“add_blank_line_after_doc_string”: true, // If true, add blank line after doc strings.

“max_seps_func_def”: 3, // Split lines containing longer function definitions.

“max_seps_func_ref”: 5, // Split lines containing longer function calls.

“max_seps_series”: 5, // Split lines containing longer lists or tuples.

“max_seps_dict”: 3, // Split lines containing longer dictionary definitions.

“max_lines_before_split_lit”: 2, // Split string literals containing more newline characters.

“left_margin”: “”, // This is how the left margin is to appear.

“normalize_doc_strings”: false, // If true, normalize white space in doc strings.

“leftjust_doc_strings”: false, // If true, left justify doc strings.

“wrap_doc_strings”: false, // If true, wrap doc strings to max_char.

“leftjust_comments”: false, // If true, left justify comments.

“wrap_comments”: false, // If true, wrap comments to max_char.

“double_quoted_strings”: false, // If true, use quotes instead of apostrophes for string literals.

“single_quoted_strings”: false, // If true, use apostrophes instead of quotes for string literals.

“can_split_strings”: false, // If true, longer strings are split at the max_char.

“doc_tab_replacement”: “….”, // This literal replaces tab characters in doc strings and comments.

// Optionally preserve unassigned constants so that code to be tidied

// may contain blocks of commented-out lines that have been no-op’ed

// with leading and trailing triple quotes. Python scripts may declare

// constants without assigning them to a variables, but CodeFormatter

// considers this wasteful and normally elides them.

“keep_unassigned_constants”: false,

// Optionally omit parentheses around tuples, which are superfluous

// after all. Normal CodeFormatter behavior will be still to include them

// as a sort of tuple display analogous to list displays, dict

// displays, and yet-to-come set displays.

“parenthesize_tuple_display”: true,

// When CodeFormatter splits longer lines because max_seps

// are exceeded, the statement normally is closed before the margin is

// restored. The closing bracket, brace, or parenthesis is placed at the

// current indent level. This looks ugly to “C” programmers. When

// java_style_list_dedent is True, the closing bracket, brace, or

// parenthesis is brought back left to the indent level of the enclosing

// statement.

“java_style_list_dedent”: false

},

“codeformatter_vbscript_options”:

{

“syntaxes”: “vbscript”, // Syntax names which must process VBScript formatter

“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”

“indent_size”: 1, // indentation size

“indent_char”: “\t”, // Indentation character

“indent_with_tabs”: true, // Indent with one tab (overrides indent_size and indent_char options)

“preserve_newlines”: true, // Preserve existing line-breaks

“max_preserve_newlines”: 10, // Maximum number of line-breaks to be preserved in one chunk

“opening_tags”: “^(Function .*|Sub .*|If .* Then|For .*|Do While .*|Select Case.*)”, // List of keywords which open a new block

“middle_tags”: “^(Else|ElseIf .* Then|Case .*)$”, // List of keywords which divide a block, but neither open or close the block

“closing_tags”: “(End Function|End Sub|End If|Next|Loop|End Select)$” // List of keywords which close an open block

},

“codeformatter_coldfusion_options”:

{

“syntaxes”: “coldfusion,cfm,cfml”, // Syntax names which must process Coldfusion Markup Language formatter

“format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “^((?!.min.|vendor).)*$”

“indent_size”: 2, // indentation size

“indent_char”: ” “, // Indentation character

“indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options)

“exception_on_tag_mismatch”: false, // If the last closing tag is not at the same indentation level as the first opening tag, there’s probably a tag mismatch in the file

“expand_javascript”: false, // (Under construction) Expand JavaScript inside of script tags (also affects CSS purely by coincidence)

“expand_tags”: false, // Expand tag attributes onto new lines

“minimum_attribute_count”: 2, // Minimum number of attributes needed before tag attributes are expanded to new lines

“first_attribute_on_new_line”: false, // Put all attributes on separate lines from the tag (only uses 1 indentation unit as opposed to lining all attributes up with the first)

“reduce_empty_tags”: false, // Put closing tags on same line as opening tag if there is no content between them

“reduce_whole_word_tags”: false, // Put closing tags on same line as opening tag if there is whole word between them

“custom_singletons”: “” // Custom singleton tags for various template languages outside of the HTML5 spec

}

}

sublime text 3怎樣安裝php插件

使用Sublime text 3 編寫代碼是一種享受,使用Sublime text 3 格式化HTML代碼,需要安裝插件,具體安裝步驟如下:1、打開菜單-首選項-插件控制,輸入 install package2、等待程序進入插件管理功能,再輸入插件名稱:TAG3、點擊安裝插件。4、插件安裝成功後,在需要格式化的HTML代碼中,選中代碼,然後按Ctrl+Alt+F對代碼進行格式化。

Sublime 安裝完phpfmt插件後,保存文件總是提示:php版本問題

這個英文的意思是你的插件使用的php版本是5.6,但是你本地的php版本是7.0。所以會有版本上的不兼容,建議你更新一下插件。

提示後面給出了插件的配置文件的地址,你打開插件的配置文件把裏面引用的php版本改成和你電腦使用的php版本一樣就可以了。

原創文章,作者:ZEHO,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/135278.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
ZEHO的頭像ZEHO
上一篇 2024-10-04 00:11
下一篇 2024-10-04 00:11

相關推薦

  • Python周杰倫代碼用法介紹

    本文將從多個方面對Python周杰倫代碼進行詳細的闡述。 一、代碼介紹 from urllib.request import urlopen from bs4 import Bea…

    編程 2025-04-29
  • Python字符串寬度不限制怎麼打代碼

    本文將為大家詳細介紹Python字符串寬度不限制時如何打代碼的幾個方面。 一、保持代碼風格的統一 在Python字符串寬度不限制的情況下,我們可以寫出很長很長的一行代碼。但是,為了…

    編程 2025-04-29
  • Python基礎代碼用法介紹

    本文將從多個方面對Python基礎代碼進行解析和詳細闡述,力求讓讀者深刻理解Python基礎代碼。通過本文的學習,相信大家對Python的學習和應用會更加輕鬆和高效。 一、變量和數…

    編程 2025-04-29
  • Python滿天星代碼:讓編程變得更加簡單

    本文將從多個方面詳細闡述Python滿天星代碼,為大家介紹它的優點以及如何在編程中使用。無論是剛剛接觸編程還是資深程序員,都能從中獲得一定的收穫。 一、簡介 Python滿天星代碼…

    編程 2025-04-29
  • 倉庫管理系統代碼設計Python

    這篇文章將詳細探討如何設計一個基於Python的倉庫管理系統。 一、基本需求 在着手設計之前,我們首先需要確定倉庫管理系統的基本需求。 我們可以將需求分為以下幾個方面: 1、庫存管…

    編程 2025-04-29
  • 寫代碼新手教程

    本文將從語言選擇、學習方法、編碼規範以及常見問題解答等多個方面,為編程新手提供實用、簡明的教程。 一、語言選擇 作為編程新手,選擇一門編程語言是很關鍵的一步。以下是幾個有代表性的編…

    編程 2025-04-29
  • Sublime Test與Python的區別

    Sublime Text是一款流行的文本編輯器,而Python是一種廣泛使用的編程語言。雖然Sublime Text可以用於編寫Python代碼,但它們之間有很多不同之處。接下來從…

    編程 2025-04-29
  • Python實現簡易心形代碼

    在這個文章中,我們將會介紹如何用Python語言編寫一個非常簡單的代碼來生成一個心形圖案。我們將會從安裝Python開始介紹,逐步深入了解如何實現這一任務。 一、安裝Python …

    編程 2025-04-29
  • 怎麼寫不影響Python運行的長段代碼

    在Python編程的過程中,我們不可避免地需要編寫一些長段代碼,包括函數、類、複雜的控制語句等等。在編寫這些代碼時,我們需要考慮代碼可讀性、易用性以及對Python運行性能的影響。…

    編程 2025-04-29
  • Python愛心代碼動態

    本文將從多個方面詳細闡述Python愛心代碼動態,包括實現基本原理、應用場景、代碼示例等。 一、實現基本原理 Python愛心代碼動態使用turtle模塊實現。在繪製一個心形的基礎…

    編程 2025-04-29

發表回復

登錄後才能評論