Sublime Text 2 右键菜单中的实用选项

Sublime Text 2 右键菜单中的实用选项

Sublime Text 2 现在已经成了 Lucifr 最常用的编辑工具了,频繁的更新不停给人带来惊喜,今天无意中发现在右键菜单(Context menu)中有几个很实用的功能。

右键菜单中的实用功能

Context Menu

  • Show Unsaved Changes...: 显示当前文件未保存的更改,而且是以 diff 的形式在输出中显示的,一目了然。

    Show Unsaved Changes

  • Reveal in Finder: 顾名思义,方便在文件系统中定位。

  • Copy File Path:复制文件的路径,很实用的功能,比如要到终端中对当前文件进行某些操作的情况。

  • Reveal in Side Bar:在侧边栏的目录树中定位当前文件,同样是非常实用的功能,便于了解当前文件在项目中的位置和整体结构的关系。

侧边栏右键功能加强

推荐通过 Package Control 安装 SideBarEnhancements 这个插件,可以大大加强在侧栏目录树中右键的选项:

SideBarEnhancements

  • 基础的一些如:新建文件/目录,编辑,打开/运行,显示,在选择中/上级目录/项目中查找,剪切,复制,粘贴,重命名,删除,刷新……

  • 很实用的 Open With,可以通过 Edit Applications 来定义程序及对应的后缀类型。可参见我的设置:

[
	{"id": "side-bar-files-open-with",
		"children":
		[

			// Marked
            {
                "caption": "Marked",
                "id": "side-bar-files-open-with-marked",
                "command": "side_bar_files_open_with",
                "args": {
                                    "paths": [],
                                    "application": "Marked.app",
                                    "extensions":"markdown|md|mdown|mkd|mkdn|txt"  //any file with these extensions
                                }
            },
            {"caption":"-"},
			//Photoshop
			{
				"caption": "Photoshop",
				"id": "side-bar-files-open-with-photoshop",

				"command": "side_bar_files_open_with",
				"args": {
									"paths": [],
									"application": "Adobe Photoshop CS5.app",
									"extensions":"psd|png|jpg|jpeg"  //any file with these extensions
								}
			},
			// Preview
            {
                "caption": "Preview",
                "id": "side-bar-files-open-with-preview",
                "command": "side_bar_files_open_with",
                "args": {
                                    "paths": [],
                                    "application": "Preview.app",
                                    "extensions":"psd|png|jpg|jpeg|gif"  //any file with these extensions
                                }
            },
			//separator
			{"caption":"-"},
			//Browsers
			{
				"caption": "Chrome",
				"id": "side-bar-files-open-with-chrome",

				"command": "side_bar_files_open_with",
				"args": {
									"paths": [],
									"application": "Google Chrome.app",
									"extensions":"html|php" //any file with extension
								}
			},

			{
                "caption": "Firefox",
                "id": "side-bar-files-open-with-firefox",
                "command": "side_bar_files_open_with",
                "args": {
                                    "paths": [],
                                    "application": "Firefox.app",
                                    "extensions":"html|php"  //any file with these extensions
                                }
            },

			{"caption":"-"},
			 // Textmate
            {
                "caption": "Textmate",
                "id": "side-bar-files-open-with-textmate",
                "command": "side_bar_files_open_with",
                "args": {
                                    "paths": [],
                                    "application": "Textmate 2.app",
                                    "extensions":".*"  //any file with these extensions
                                }
            }

		]
	}
]
  • 很牛的 Copy as Text...:包含各种形式的路径、URI(甚至包括 base64 的 data:uri)、转码后的文件名、各种 HTML Tag(a、img、script、style)……

欢迎关注 Sublime Text 这个标签,Lucifr 会继续分享更多相关的技巧和信息。