

<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sublime &#8211; Max的程式語言筆記</title>
	<atom:link href="https://stackoverflow.max-everyday.com/tag/sublime/feed/" rel="self" type="application/rss+xml" />
	<link>https://stackoverflow.max-everyday.com</link>
	<description>我要當一個豬頭，快樂過每一天</description>
	<lastBuildDate>Mon, 27 Apr 2026 06:46:52 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://stackoverflow.max-everyday.com/wp-content/uploads/2017/02/max-stackoverflow-256.png</url>
	<title>sublime &#8211; Max的程式語言筆記</title>
	<link>https://stackoverflow.max-everyday.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Sublime Text 的「尋找」的正規表達式預設是不比對換行符號</title>
		<link>https://stackoverflow.max-everyday.com/2025/10/sublime-text-return-line-regex/</link>
					<comments>https://stackoverflow.max-everyday.com/2025/10/sublime-text-return-line-regex/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Wed, 22 Oct 2025 17:26:05 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<category><![CDATA[sublime]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=7164</guid>

					<description><![CDATA[透過 sublime 想移除某一個 html 的...]]></description>
										<content:encoded><![CDATA[
<p>透過 sublime 想移除某一個 html 的 tag, 直接使用 &lt;tab .*/tag>在沒有遇到換行符號都沒問題,  但有換行時就無法選取到換行後的內容。</p>



<p>解法是把 <code>.*</code> 換成 <code>([\s\S]*?)</code></p>



<p>原始的 html:</p>



<pre class="wp-block-code"><code>&lt;div id="byline-container" class="style-scope ytd-playlist-panel-video-renderer">
&lt;span id="byline" class="style-scope ytd-playlist-panel-video-renderer">
Hgfdoi
&lt;/span>
&lt;/div></code></pre>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="127" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2025/10/2025-10-23_01-17_cf-1024x127.jpg?v=1761153810" alt="" class="wp-image-7166" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2025/10/2025-10-23_01-17_cf-1024x127.jpg?v=1761153810 1024w, https://stackoverflow.max-everyday.com/wp-content/uploads/2025/10/2025-10-23_01-17_cf-600x74.jpg?v=1761153810 600w, https://stackoverflow.max-everyday.com/wp-content/uploads/2025/10/2025-10-23_01-17_cf-768x95.jpg?v=1761153810 768w, https://stackoverflow.max-everyday.com/wp-content/uploads/2025/10/2025-10-23_01-17_cf.jpg?v=1761153810 1416w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>在 Sublime Text 的「尋找」(Ctrl+F 或 Cmd+F) 或「在檔案中尋找」(Ctrl+Shift+F 或 Cmd+Shift+F) 面板中，正規表達式預設是<strong>不比對換行符號</strong>的。</p>



<p>要解決這個問題，您需要做兩件事：</p>



<ol start="1" class="wp-block-list">
<li><strong>啟用「點號比對新行」（Dot Matches Newline）模式</strong>：在 Sublime Text 的尋找面板中，這通常對應於一個特殊的模式修飾符或一個按鈕。</li>



<li><strong>調整您的正規表達式</strong>：確保它能處理換行。</li>
</ol>



<h3 class="wp-block-heading">解決方案</h3>



<h4 class="wp-block-heading">1. 使用模式修飾符（推薦）</h4>



<p>在 Sublime Text 的正規表達式引擎（預設是基於 Boost 的 PCRE）中，您可以在表達式的<strong>開頭</strong>添加 <code>(?s)</code> 修飾符來啟用「點號比對新行」（<code>s</code> 代表 <strong>single-line mode</strong> 或 <strong>dot-all</strong>）。</p>



<p><strong>修改後的正規表達式：</strong></p>



<p>程式碼片段</p>



<pre class="wp-block-code"><code>(?s)&lt;span id="byline" (.*?)&lt;/span&gt;
</code></pre>



<p><strong>解釋：</strong></p>



<ul class="wp-block-list">
<li><code>(?s)</code>: 啟用單行模式。在這個模式下，點號 (<code>.</code>) 會比對包括換行符號在內的任何字元。</li>



<li><code>&lt;span id="byline" </code>: 比對起始部分。</li>



<li><code>(.*?)</code>: <strong>非貪婪</strong>地擷取中間的所有內容，包括屬性和標籤內的文字。
<ul class="wp-block-list">
<li><code>*?</code> 確保它只比對到最近的 <code>&lt;/span></code> 標籤。</li>
</ul>
</li>



<li><code>&lt;/span></code>: 比對結束標籤。</li>
</ul>



<h4 class="wp-block-heading">2. 使用專門比對任何字元的表達式（替代方案）</h4>



<p>如果您不想使用 <code>(?s)</code> 修飾符，您可以將 <code>.</code> 替換為能夠比對任何字元組合的模式，例如：</p>



<p>程式碼片段</p>



<pre class="wp-block-code"><code>&lt;span id="byline" (&#91;\s\S]*?)&lt;/span&gt;
</code></pre>



<p><strong>解釋：</strong></p>



<ul class="wp-block-list">
<li><code>[\s\S]</code>: 這是一個字元集，它比對：
<ul class="wp-block-list">
<li><code>\s</code>: 任何空白字元（包括空格、製表符、<strong>換行符號</strong>）。</li>



<li><code>\S</code>: 任何非空白字元。</li>



<li>結合起來，它比對<strong>所有</strong>字元。</li>
</ul>
</li>



<li><code>[\s\S]*?</code>: <strong>非貪婪</strong>地比對所有內容。</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 額外的建議 (針對您的 HTML 結構)：</strong></p>



<p>如果您只需要擷取 <code>&lt;span&gt;</code> 標籤<strong>內部的文字</strong>，您的原始 HTML 結構是：</p>



<p>HTML</p>



<pre class="wp-block-code"><code>&lt;span id="byline" class="style-scope ytd-playlist-panel-video-renderer"&gt;
    Hgfdoi
&lt;/span&gt;
</code></pre>



<p>如果您使用 <code>(?s)&lt;span id="byline" (.*?)&lt;/span&gt;</code>，它會擷取到：</p>



<ol start="1" class="wp-block-list">
<li><code>class="style-scope ytd-playlist-panel-video-renderer"</code></li>



<li><code>></code></li>



<li><code>\n</code>（換行符號）</li>



<li><code>Hgfdoi</code></li>



<li><code>\n</code>（換行符號）</li>
</ol>



<p>如果您只想提取 <code>Hgfdoi</code>，並且處理所有屬性和空白字元，更精確的表達式是：</p>



<p>程式碼片段</p>



<pre class="wp-block-code"><code>(?s)&lt;span id="byline".*?&gt;(.*?)&lt;/span&gt;
</code></pre>



<ul class="wp-block-list">
<li><code>(?s)</code>: 開啟比對換行。</li>



<li><code>&lt;span id="byline"</code>: 比對起始。</li>



<li><code>.*?</code>: 非貪婪地比對所有屬性直到 <code>></code> 符號。</li>



<li><code>></code>: 比對起始標籤的結束符號。</li>



<li><code>(.*?)</code>: <strong>擷取群組</strong>，擷取您想要的文字（<code>Hgfdoi</code> 和周圍的空白換行）。</li>



<li><code>&lt;/span></code>: 比對結束標籤。</li>
</ul>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2025/10/sublime-text-return-line-regex/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[sublime] How can I set word wrap turned on by default?</title>
		<link>https://stackoverflow.max-everyday.com/2020/03/sublime-wrap-turned-off-by-default/</link>
					<comments>https://stackoverflow.max-everyday.com/2020/03/sublime-wrap-turned-off-by-default/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Thu, 12 Mar 2020 17:03:49 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[sublime]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=3278</guid>

					<description><![CDATA[每天都會用到 sublime, 大多都是透過指令...]]></description>
										<content:encoded><![CDATA[
<p>每天都會用到  sublime, 大多都是透過指令的方式，使用 sublime 開啟文字檔。</p>



<p>最近遇到的問題是，每次都需要手動去把「換行」wrap 給關掉，預設是 &#8220;auto&#8221;，幾乎都幫我換行，我不太喜歡自動換行的功能。</p>



<p>解法：<br><a href="https://forum.sublimetext.com/t/how-can-i-set-word-wrap-turned-on-by-default/573">https://forum.sublimetext.com/t/how-can-i-set-word-wrap-turned-on-by-default/573</a></p>



<p>go to Preferences &gt; File Settings — Default, you can see that the option is now this:</p>



<pre class="wp-block-code"><code>	"word_wrap": true,</code></pre>



<p>把左邊視窗裡的預設值複到到右邊 user 的框框裡，就完成了。</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="400" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-13-at-01.04.35-1024x400.jpg?v=1584032721" alt="" class="wp-image-3280" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-13-at-01.04.35-1024x400.jpg?v=1584032721 1024w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-13-at-01.04.35-600x234.jpg?v=1584032721 600w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-13-at-01.04.35-768x300.jpg?v=1584032721 768w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-13-at-01.04.35-1536x599.jpg?v=1584032721 1536w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-13-at-01.04.35.jpg?v=1584032721 1958w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2020/03/sublime-wrap-turned-off-by-default/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>在 sublime 裡刪除空白行</title>
		<link>https://stackoverflow.max-everyday.com/2019/11/how-to-delete-blank-lines-from-selection-in-sublime-text/</link>
					<comments>https://stackoverflow.max-everyday.com/2019/11/how-to-delete-blank-lines-from-selection-in-sublime-text/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Thu, 21 Nov 2019 07:21:17 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[sublime]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=3094</guid>

					<description><![CDATA[HOW TO DELETE BLANK LINE...]]></description>
										<content:encoded><![CDATA[
<p>HOW TO DELETE BLANK LINES FROM SELECTION IN SUBLIME TEXT.</p>



<p>我是 sublime 的愛好者，在使用免費的版本一陣子後，在剛好有收入的情況下，也有讚助作者購買其序號，真的是一個好用的編輯器。</p>



<p>不像是 notepad++, sublime 的選單裡預設沒有刪除空白行的功能，需要手動操作：</p>



<p>Select the text</p>



<p>Press:</p>



<ul class="wp-block-list"><li>Ctrl&nbsp;+&nbsp;H&nbsp;on PC, or</li><li>Command&nbsp;+&nbsp;Alt&nbsp;+&nbsp;F&nbsp;on Mac or</li><li>Click Find-&gt;Replace.</li></ul>



<p>Make sure you have selected &#8216;regular expression&#8217; by pressing:</p>



<ul class="wp-block-list"><li>Alt&nbsp;+&nbsp;R&nbsp;on PC or</li><li>Command&nbsp;+&nbsp;Alt&nbsp;+&nbsp;R&nbsp;on Mac or</li><li>Click&nbsp;.*&nbsp;in the Find box.</li></ul>



<p>Find what:&nbsp;<code>^\n</code></p>



<p>Replace With: (nothing, leave in blank).</p>



<hr class="wp-block-separator"/>



<p>上面的操作都太複雜，最佳解法是：<br><a href="https://packagecontrol.io/packages/DeleteBlankLines">https://packagecontrol.io/packages/DeleteBlankLines</a></p>



<ol class="wp-block-list"><li>Press CTRL + SHIFT + P (macOS 是 cmd+shift+p)</li><li>Type Install onto the dialog window</li><li>Select “<strong>Package Control: Install Package</strong>” and press “Enter”</li><li>Search for and install “<strong>DeleteBlankLines</strong>”</li></ol>



<p>然後在  menubar 的 Edit &#8211; Line 的目錄裡，就會多出一個 delete blank lines 的選項。</p>



<figure class="wp-block-image size-large"><img decoding="async" width="725" height="414" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/09/Screen-Shot-2020-09-29-at-21.45.52.png" alt="" class="wp-image-3535" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2020/09/Screen-Shot-2020-09-29-at-21.45.52.png?v=1601387194 725w, https://stackoverflow.max-everyday.com/wp-content/uploads/2020/09/Screen-Shot-2020-09-29-at-21.45.52-600x343.png?v=1601387194 600w" sizes="(max-width: 725px) 100vw, 725px" /></figure>



<p></p>



<hr class="wp-block-separator"/>



<h2 class="wp-block-heading">Shortcut Keys</h2>



<p>Windows: &#8211; Ctrl+Alt+Backspace –&gt; Delete Blank Lines &#8211; Ctrl+Alt+Shift+Backspace –&gt; Delete Surplus Blank Lines</p>



<p>OSX: &#8211; Fn+Ctrl+Option+Delete –&gt; Delete Blank Lines &#8211; Fn+Ctrl+Option+Shift+Delete –&gt; Delete Surplus Blank Lines</p>



<p>Linux: &#8211; Ctrl+Alt+Backspace –&gt; Delete Blank Lines &#8211; Ctrl+Alt+Shift+Backspace –&gt; Delete Surplus Blank Lines</p>



<p>如果你有外接鍵盤的話，在 mac OSX 請使用 &#8220;<strong>Delete</strong>&#8221; 鍵，而不是 &#8220;<strong>Backspace</strong>&#8221; 鍵。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2019/11/how-to-delete-blank-lines-from-selection-in-sublime-text/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>sublime html encode</title>
		<link>https://stackoverflow.max-everyday.com/2017/09/sublime-html-encode/</link>
					<comments>https://stackoverflow.max-everyday.com/2017/09/sublime-html-encode/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Wed, 06 Sep 2017 06:07:17 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[sublime]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=1251</guid>

					<description><![CDATA[上次使用 sublime 幫 java 的 so...]]></description>
										<content:encoded><![CDATA[<p>上次<a href="https://stackoverflow.max-everyday.com/2017/08/sublime-text-sublimeastyleformatter/">使用 sublime 幫 java 的 source code format</a> 效果很好，這次希望 sublime 可以幫我做html encode。</p>
<h4>SublimeAStyleFormatter Plugin  的安裝方式：</h4>
<p>用 Package Install 來安裝～</p>
<p>Sublime Text &gt; Tools &gt; Command Palette &gt; Package Control: Install Package，</p>
<p>找到 StringEncode 安裝～</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1252" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2017/09/Screenshot-2017-09-06-13.59.54.jpg" alt="" width="800" height="202" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2017/09/Screenshot-2017-09-06-13.59.54.jpg 800w, https://stackoverflow.max-everyday.com/wp-content/uploads/2017/09/Screenshot-2017-09-06-13.59.54-600x152.jpg 600w, https://stackoverflow.max-everyday.com/wp-content/uploads/2017/09/Screenshot-2017-09-06-13.59.54-768x194.jpg 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></p>
<p>&nbsp;</p>
<p>You can use more functional plugin <a href="https://github.com/colinta/SublimeStringEncode" rel="nofollow">SublimeStringEncode</a>.</p>
<ol>
<li>Install it using Package Control, type &#8220;StringEncode&#8221;.</li>
<li><kbd>cmd</kbd> + <kbd>shift</kbd> + <kbd>P</kbd> then 在輸入框裡輸 &#8220;HTML entitize&#8221; 就可以看到 StringEncode 提供的function，超神奇，好好用的。</li>
</ol>
<hr />
<p>In addition you will have some other useful commands:</p>
<ul>
<li><code>html_deentitize</code>: Converts HTML entities to a character</li>
<li><code>url_encode</code>: Uses urllib.quote to escape special URL characters</li>
<li><code>url_decode</code>: Uses urllib.unquote to convert escaped URL characters</li>
<li><code>json_escape</code>: Escapes a string and surrounds it in quotes, according to the JSON encoding.</li>
<li><code>json_unescape</code>: Unescapes a string (include the quotes!) according to JSON encoding.</li>
<li><code>base64_encode</code>: Uses base64 to encode into base64</li>
<li><code>base64_decode</code>: Uses base64 to decode from base64</li>
<li><code>md5_encode</code>: Uses sha package to create md5 hash</li>
<li><code>sha256_encode</code>: Uses sha package to create sha256 hash</li>
<li><code>sha512_encode</code>: Uses sha package to create sha512 hash</li>
<li><code>escape_regex</code>: Escapes regex meta characters</li>
<li><code>escape_like</code>: Escapes SQL-LIKE meta characters</li>
<li><code>safe_html_entitize</code>: Converts characters to their HTML entity, but preserves HTML reserved characters</li>
<li><code>safe_html_deentitize</code>: Converts HTML entities to a character, but preserves HTML reserved characters</li>
<li><code>xml_entitize</code>: Converts characters to their XML entity</li>
<li><code>xml_deentitize</code>: Converts XML entities to a character</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2017/09/sublime-html-encode/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[SUBLIME TEXT] 使用 CoolFormat 套用程式碼樣式</title>
		<link>https://stackoverflow.max-everyday.com/2017/08/sublime-text-sublimeastyleformatter/</link>
					<comments>https://stackoverflow.max-everyday.com/2017/08/sublime-text-sublimeastyleformatter/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Thu, 10 Aug 2017 01:21:56 +0000</pubDate>
				<category><![CDATA[Java筆記]]></category>
		<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[sublime]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=1048</guid>

					<description><![CDATA[我自己習慣使用 CoolFormat 這個套件 ...]]></description>
										<content:encoded><![CDATA[
<p>我自己習慣使用 CoolFormat 這個套件</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="122" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2024/04/Screenshot-2024-04-24-at-4.13.31 PM-1024x122.png?v=1713946461" alt="" class="wp-image-5667" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2024/04/Screenshot-2024-04-24-at-4.13.31 PM-1024x122.png?v=1713946461 1024w, https://stackoverflow.max-everyday.com/wp-content/uploads/2024/04/Screenshot-2024-04-24-at-4.13.31 PM-600x72.png?v=1713946461 600w, https://stackoverflow.max-everyday.com/wp-content/uploads/2024/04/Screenshot-2024-04-24-at-4.13.31 PM-768x92.png?v=1713946461 768w, https://stackoverflow.max-everyday.com/wp-content/uploads/2024/04/Screenshot-2024-04-24-at-4.13.31 PM.png?v=1713946461 1208w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>這真的滿神奇的小工具，AStyle Formatter 預設會讓第一個大括號停在 if 或 fuction 的同一行。如果想讓第1個左大括號下去單獨一行需要修改設定值。</p>



<p>SublimeAStyleFormatter is a simple code formatter plugin for Sublime Text. It provides ability to format C, C++, Cuda-C++, OpenCL, Arduino, C#, and Java files.</p>



<p>原作者的github:<br><a href="https://github.com/akof1314/CoolFormat">https://github.com/akof1314/CoolFormat</a></p>



<p>CoolFormat 在 windows 平台上，使用上都沒問題，但在macOS 上做 format，就會卡關. </p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>建議改用：<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-red-color">Prettierd Format</mark></strong><br><a href="https://packagecontrol.io/packages/Prettierd%20Format">https://packagecontrol.io/packages/Prettierd%20Format</a></p>



<p>使用 prettierd format 前一定要先安裝元件, 否則在存檔時會出現錯誤訊息:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="399" height="245" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2017/08/sublime_text_2026-04-27-14-28-6g.jpg?v=1777271932" alt="" class="wp-image-8357"/></figure>



<p>In order to start using this plugin, you must install prettierd globally, either using npm/yarn/pnpm:</p>



<pre class="wp-block-code"><code>  npm i -g @fsouza/prettierd</code></pre>



<p>or homebrew on macOS:</p>



<pre class="wp-block-code"><code>  brew install fsouza/prettierd/prettierd</code></pre>



<p>Then, format on save will be enabled by default for all files supported by Prettier out-of-the-box.</p>



<p>### Commands:</p>



<ul class="wp-block-list">
<li>Prettierd: Format</li>
</ul>



<p>Prettierd Format 使用起來也怪怪的，預設居然存檔會 format 一次！</p>



<p>解法很簡單，Formatter settings can be accessed from: Preferences &gt; Package Settings &gt; Prettierd  Format &gt; Settings，設定存檔時不要自動 format</p>



<pre class="wp-block-code"><code>"format_on_save": false</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>改用 Formatter<br><a href="https://github.com/bitst0rm-pub/Formatter">https://github.com/bitst0rm-pub/Formatter</a></p>



<p>Formatter 感覺是很強沒錯，但觸發要用右鍵，不太直覺，希望都可以用鍵盤來解決。</p>



<p>設定方式：<br><a href="https://packagecontrol.io/packages/Formatter">https://packagecontrol.io/packages/Formatter</a></p>



<p>Formatter settings can be accessed from: Preferences &gt; Package Settings &gt; Formatter &gt; Settings</p>



<p>The following setting details &#8211; along with their default values and examples &#8211; are provided to guide you on how to set it up.</p>



<p><em>Formatter.sublime-settings</em></p>



<pre class="wp-block-preformatted">{
    "debug"<strong>:</strong> "status",

    "auto_format"<strong>:</strong> {
        "config"<strong>:</strong> {
            "format_on_save"<strong>:</strong> <strong>false</strong>,
            "format_on_paste"<strong>:</strong> <strong>false</strong>
        },
        "json"<strong>:</strong> {
            "uid"<strong>:</strong> "jsbeautifier"
        },
        "html"<strong>:</strong> {
            "uid"<strong>:</strong> "jsbeautifier",
            "exclude_syntaxes"<strong>:</strong> {
                "html"<strong>:</strong> ["markdown"]
            }
        },
        "python"<strong>:</strong> {
            "uid"<strong>:</strong> "autopep8"
        }
    },

    "formatters"<strong>:</strong> {}
}</pre>



<p>如果想用 Fomatter 格式化 html 格式，需要安裝：</p>



<figure class="wp-block-table"><table><tbody><tr><td>HTML, XHTML, XML</td><td><a href="https://github.com/beautify-web/js-beautify">js-beautifier</a>,&nbsp;<a href="https://github.com/prettier/prettier">prettier</a>,&nbsp;<a href="https://github.com/fsouza/prettierd">prettierd</a>,&nbsp;<a href="https://github.com/prettydiff/prettydiff">prettydiff</a>[1],&nbsp;<a href="https://github.com/htacg/tidy-html5">html-tidy</a></td></tr></tbody></table></figure>



<p>滿神奇的，在 sublime 安裝完 js-beautifier ，使用 cmd + shift + p, 輸入 html 就會看到 html prettify, 可以格式化 html. </p>



<p></p>



<p>如果想用 Formatter 格式化 java, 有這幾個解法：</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td>Java</td><td><a href="https://github.com/google/google-java-format">google java format</a>&nbsp;[1],&nbsp;<a href="https://github.com/uncrustify/uncrustify">uncrustify</a>&nbsp;[2],&nbsp;<a href="https://clang.llvm.org/docs/ClangFormat.html">clang-format</a>&nbsp;[3],&nbsp;<a href="https://sourceforge.net/projects/astyle">artistic style</a></td></tr></tbody></table></figure>



<p></p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>改用 JsFormat<br><a href="https://github.com/jdavisclark/JsFormat">https://github.com/jdavisclark/JsFormat</a></p>



<p>在 macOS 上，似乎 JsFormat 用起來是比較順手。</p>



<h2 class="wp-block-heading">Settings</h2>



<p>JsFormat uses whatever tab/indent settings are configured with the standard&nbsp;<code>translate_tabs_to_spaces</code>&nbsp;and&nbsp;<code>tab_size</code>&nbsp;sublime settings.</p>



<p>The following&nbsp;<strong>JsBeautifier</strong>&nbsp;settings are available in JsFormat/JsFormat.sublime-settings (defaults shown below). Check out the official&nbsp;<a href="https://github.com/einars/js-beautify#options">jsbeautifier documentation</a>&nbsp;for more details on the options:</p>



<ul class="wp-block-list">
<li><code>indent_with_tabs</code>: false</li>



<li><code>max_preserve_newlines</code>: 4</li>



<li><code>preserve_newlines</code>: true</li>



<li><code>space_in_paren</code>: false</li>



<li><code>jslint_happy</code>: false</li>



<li><code>brace_style</code>: “collapse”</li>



<li><code>keep_array_indentation</code>: false</li>



<li><code>keep_function_indentation</code>: false</li>



<li><code>eval_code</code>: false,</li>



<li><code>unescape_strings</code>: false,</li>



<li><code>break_chained_methods</code>: false*</li>



<li><code>e4x</code>: false</li>



<li><code>wrap_line_length</code>: 0</li>



<li><code>space_after_anon_function</code>: false</li>
</ul>



<p>The following&nbsp;<strong>JsFormat</strong>&nbsp;specific settings are also exposed:</p>



<ul class="wp-block-list">
<li><code>format_on_save</code>: false (format files on buffer save)</li>



<li><code>format_on_save_extensions</code>:&nbsp;<a href="https://github.com/jdavisclark/JsFormat/blob/master/extensions%20of%20files%20that%20will%20be%20formatted%20on%20save">[“js”, “json”]</a></li>



<li><code>jsbeautifyrc_files</code>: false (see the&nbsp;<a href="https://packagecontrol.io/packages/JsFormat#jsbeautifyrc-files">.jsbeautifyrc files</a>&nbsp;section)</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>


<p>Mac 上的修改方式，先開啟檔案：</p>
<p>~/Library/Application Support/Sublime Text 3/Packages/SublimeAStyleFormatter/SublimeAStyleFormatter.sublime-settings：</p>
<pre>{
// Please visit http://astyle.sourceforge.net/astyle.html for more information
"options_default": {
// Default bracket style
// Can be one of "allman", "bsd", "break", "java", "attach", "kr", "k&amp;r",
// "k/r" "stroustrup", "whitesmith", "banner", "gnu", "linux", "horstmann",
// "1tbs", "otbs ", "google", "pico", "lisp", "python", "vtk", or null
// for default.
"style": "allman",
}
}
</pre>
<hr />
<h4>SublimeAStyleFormatter Plugin  的安裝方式：</h4>
<p>用 Package Install 來安裝～</p>
<p>Sublime Text &gt; Tools &gt; Command Palette &gt; Package Control: Install Package，</p>
<p>找到 SublimeAStyleFormatter 安裝～</p>
<hr />
<h4>SublimeAStyleFormatter Plugin  的使用方式：</h4>
<p>選擇 Tools &gt; Command Palette &gt; SublimeAStyleFormatter: Format Current File，</p>
<p>就可以套用樣式了～</p>
<p>輸入 「format」就可以看到 command:</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1050" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2017/08/Screenshot-2017-08-10-09.16.28.jpg" alt="" width="914" height="212" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2017/08/Screenshot-2017-08-10-09.16.28.jpg 914w, https://stackoverflow.max-everyday.com/wp-content/uploads/2017/08/Screenshot-2017-08-10-09.16.28-600x139.jpg 600w, https://stackoverflow.max-everyday.com/wp-content/uploads/2017/08/Screenshot-2017-08-10-09.16.28-768x178.jpg 768w" sizes="auto, (max-width: 914px) 100vw, 914px" /></p>
<p>熱鍵是 Ctrl + Option + F</p>
<hr />
<p>官方的貼心說明文件：</p>
<h2>Usage</h2>
<h3><a id="user-content-key-bindings" class="anchor" href="https://github.com/timonwong/SublimeAStyleFormatter#key-bindings" aria-hidden="true"></a>Key Bindings</h3>
<p>The default key bindings for this plugin:</p>
<p><strong>Windows, Linux:</strong></p>
<ul>
<li><kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>F</kbd>: Format current file.</li>
<li><kbd>Ctrl</kbd>+<kbd>K</kbd>, <kbd>Ctrl</kbd>+<kbd>F</kbd>: Format current selection.</li>
</ul>
<p><strong>OSX:</strong></p>
<ul>
<li><kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>F</kbd>: Format current file.</li>
<li><kbd>⌘</kbd>+<kbd>K</kbd>, <kbd>⌘</kbd>+<kbd>F</kbd>: Format current selection.</li>
</ul>
<h3><a id="user-content-command-palette" class="anchor" href="https://github.com/timonwong/SublimeAStyleFormatter#command-palette" aria-hidden="true"></a>Command Palette</h3>
<p>Open the command palette, it appears as <code>SublimeAStyleFormatter: Format Current File</code> and <code>SublimeAStyleFormatter Format Current Selection</code>.</p>
<h2><a id="user-content-settings" class="anchor" href="https://github.com/timonwong/SublimeAStyleFormatter#settings" aria-hidden="true"></a>Settings</h2>
<h3><a id="user-content-per-project-settings" class="anchor" href="https://github.com/timonwong/SublimeAStyleFormatter#per-project-settings" aria-hidden="true"></a>Per-project Settings</h3>
<p>Before starting, you may want to have a look at SublimeAStyleFormatter.sublime-settings.</p>
<p>To edit your project setting, select <code>Project/Edit Project</code> from main menu. A project setting contains per-project settings for SublimeAStyleFormatter should look like this:</p>
<div class="highlight highlight-source-js">
<pre>{
    <span class="pl-s"><span class="pl-pds">"</span>settings<span class="pl-pds">"</span></span><span class="pl-k">:</span>
    {
        <span class="pl-s"><span class="pl-pds">"</span>AStyleFormatter<span class="pl-pds">"</span></span><span class="pl-k">:</span>
        {
        }
    }
}</pre>
</div>
<p>For example, if you don&#8217;t want to inherit the default settings, instead, use your own astylerc file for C and C++ individually, then your project setting might look like this:</p>
<div class="highlight highlight-source-js">
<pre>{
    <span class="pl-c">// project folders, etc</span>
    <span class="pl-c">// ...</span>
    <span class="pl-c">// project settings</span>
    <span class="pl-s"><span class="pl-pds">"</span>settings<span class="pl-pds">"</span></span><span class="pl-k">:</span>
    {
        <span class="pl-s"><span class="pl-pds">"</span>AStyleFormatter<span class="pl-pds">"</span></span><span class="pl-k">:</span>
        {
            <span class="pl-s"><span class="pl-pds">"</span>options_default<span class="pl-pds">"</span></span><span class="pl-k">:</span>
            {
                <span class="pl-c">// Use 2 spaces for indentation</span>
                <span class="pl-s"><span class="pl-pds">"</span>indent<span class="pl-pds">"</span></span><span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>spaces<span class="pl-pds">"</span></span>,
                <span class="pl-s"><span class="pl-pds">"</span>indent-spaces<span class="pl-pds">"</span></span><span class="pl-k">:</span> <span class="pl-c1">2</span>
            },
            <span class="pl-s"><span class="pl-pds">"</span>options_c<span class="pl-pds">"</span></span><span class="pl-k">:</span>
            {
                <span class="pl-s"><span class="pl-pds">"</span>use_only_additional_options<span class="pl-pds">"</span></span><span class="pl-k">:</span> <span class="pl-c1">true</span>,
                <span class="pl-s"><span class="pl-pds">"</span>additional_options_file<span class="pl-pds">"</span></span><span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>/path/to/your/astylerc/for/c<span class="pl-pds">"</span></span>
            },
            <span class="pl-s"><span class="pl-pds">"</span>options_c++<span class="pl-pds">"</span></span><span class="pl-k">:</span>
            {
                <span class="pl-s"><span class="pl-pds">"</span>use_only_additional_options<span class="pl-pds">"</span></span><span class="pl-k">:</span> <span class="pl-c1">true</span>,
                <span class="pl-s"><span class="pl-pds">"</span>additional_options_file<span class="pl-pds">"</span></span><span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>/path/to/your/astylerc/for/c++<span class="pl-pds">"</span></span>
            }
        }
    }
}

</pre>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2017/08/sublime-text-sublimeastyleformatter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Launch Sublime Text  from the Mac OS X Terminal</title>
		<link>https://stackoverflow.max-everyday.com/2017/06/launch-sublime-text-from-the-mac-os-x-terminal/</link>
					<comments>https://stackoverflow.max-everyday.com/2017/06/launch-sublime-text-from-the-mac-os-x-terminal/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Sat, 03 Jun 2017 17:43:30 +0000</pubDate>
				<category><![CDATA[電腦相關應用]]></category>
		<category><![CDATA[macOS]]></category>
		<category><![CDATA[sublime]]></category>
		<guid isPermaLink="false">http://stackoverflow.max-everyday.com/?p=904</guid>

					<description><![CDATA[透過指令開啟特定的檔案們進sublime 這個真...]]></description>
										<content:encoded><![CDATA[
<p>透過指令開啟特定的檔案們進sublime 這個真的超方便的。</p>



<p>version 2:</p>



<pre class="wp-block-code"><code>sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl</code></pre>



<p>應該沒人在用 2 了，應該都升到4 了。</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>version 3 / 4:</p>



<pre class="wp-block-code"><code>sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>不知道自己用的是 &nbsp;version 2 還是 version 3 就到 terminal 裡 ls 一下 /Applications 就知道了。</p>



<p>附註：用 sub 比 用 subl 效果好，因為可以少打一個單久，打久 sub 會習慣 sub.</p>



<p>說明：上面的2個sample 各別是 ln 到 ~/usr/bin &nbsp;和 /usr/local/bin</p>



<p>應該是要到 &nbsp;/usr/local/bin 才對，但如果你沒有這個資料夾，可以先 mkdir 一下。</p>



<pre class="wp-block-preformatted">mkdir /usr/local/bin</pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>from：</p>



<p>OS X Command Line<br><a href="https://www.sublimetext.com/docs/2/osx_command_line.html">https://www.sublimetext.com/docs/2/osx_command_line.html</a></p>



<p>Launch Sublime Text 3 from the command line<br><a href="http://olivierlacan.com/posts/launch-sublime-text-3-from-the-command-line/">http://olivierlacan.com/posts/launch-sublime-text-3-from-the-command-line/</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2017/06/launch-sublime-text-from-the-mac-os-x-terminal/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
