如何更改崇高文本3中的默认代码片段?

时间:2022-11-22 19:59:40

I know how to edit the snippets myself, just can't seem to be able to find the default ones in the new version of Sublime Text.

我自己就知道如何编辑这些片段,但似乎无法在新版的崇高文本中找到默认的片段。

EDIT: The snippet I am trying to find and consequently edit is the default for the Latex files, in particular the one that converts from:

编辑:我正在寻找并因此而编辑的代码片段是乳胶文件的默认格式,特别是从:

sec

to

\section{section name} % (fold)
\label{sec:section_name}

3 个解决方案

#1


131  

Sublime Text 3 stores its packages in .sublime-package zip files (the location varies by OS), so unlike ST2 you can't just go to the Packages folder and see everything. However, there is an excellent plugin called PackageResourceViewer (available via Package Control) that can, among other things, extract files or whole packages to the Packages directory.

在.sublime-package zip文件中存储它的包(位置因操作系统而异),所以与ST2不同的是,您不能直接访问包文件夹并查看所有内容。但是,有一个叫做PackageResourceViewer的优秀插件(可以通过包控件获得),它可以将文件或整个包提取到包目录中。

Once you've installed the plugin:

一旦你安装了插件:

  • hit CtrlShiftP to open the command palette
  • 按下ctrl lshiftp打开命令调色板
  • type prv to get the Package Resource Viewer: options
  • 类型prv获取包资源查看器:选项。
  • select Package Resource Viewer: Open Resource
  • 选择Package Resource Viewer: Open Resource
  • navigate down the list to LaTeX
  • 导航到LaTeX列表
  • then open the section-..-(section).sublime-snippet file.
  • 然后打开部分- . .(部分)。sublime-snippet文件。

You should now be able to edit this file and save it, which will create a new file Packages/LaTeX/section-..-(section).sublime-snippet that you can open directly via the file menu if you need to alter it again.

您现在应该能够编辑这个文件并保存它,它将创建一个新的文件包/LaTeX/section-..-(section)。sublime-snippet,如果需要再次更改它,您可以通过file菜单直接打开它们。

If you'd like to work on multiple files, or an entire package, use Package Resource Viewer: Extract Package which will unzip everything into the Packages/PackageName folder. Please keep in mind, though, that once packages or individual files are extracted into the Packages folder, they overrule files of the same name located in the .sublime-package archive. This is good for customization, but if at some point the parent package is updated, you won't see the effects because they're being masked by what's in Packages. Therefore, it's probably best to extract only what you need, and keep an eye on your package updates in case new features are introduced that you want to take advantage of.

如果您想处理多个文件或整个包,请使用package Resource Viewer: Extract package,它将把所有文件解压到Packages/PackageName文件夹中。但是请记住,一旦将包或单个文件提取到包文件夹中,它们就会覆盖位于.sublime-package归档文件中的同名文件。这对于自定义很有好处,但是如果在某个时候父包被更新,您将看不到效果,因为它们被包中的内容所掩盖。因此,最好只提取您需要的内容,并关注您的包更新,以防您想要利用的新特性被引入。

Good luck!

好运!

#2


2  

To easily jump there in terminal (if you are using ST3 on OSX) is /Users/$USER/Library/Application\ Support/Sublime\ Text\ 3/Packages/User. You can see all of your snippets here and edit them as you like.

要在终端上轻松跳转(如果你在OSX上使用ST3)是/Users/$USER/Library/Application\ Support/Sublime\ Text\ 3/Packages/ USER。您可以在这里看到所有的代码片段,并按自己的喜好编辑它们。

#3


2  

In addition to the other answer, here is how to do it without having to install any additional plugin.

除了其他的答案,下面是如何在不需要安装任何额外插件的情况下完成它。

Solution not requiring any additional plugin (October 2016).


I had a similar problem while trying to override some key bindings defined in a package.

我在尝试覆盖包中定义的一些键绑定时遇到了类似的问题。

Steps

  • Install your package (using Package Manager or any other method you prefer).
  • 安装您的包(使用包管理器或您喜欢的任何其他方法)。

Your zipped package file should be now placed within the folder ~/.config/sublime-text-3/Installed Packages/<your-package>.sublime-package.

压缩包文件现在应该放在~/文件夹中。配置/ sublime-text-3 / / <包> .sublime-package安装包。

  • Check the content of the package by unzipping it (just make sure to keep the original zipped file).

    通过解压来检查包的内容(只要确保保留原来的压缩文件)。

    Among these files, find the one that contains the preference you want to edit (see Package Contents). In your case it should be a .sublime-snippet file. Remember its name.

    在这些文件中,找到包含要编辑的首选项的文件(请参阅包内容)。在您的情况下,它应该是.sublime-snippet文件。记住它的名字。

  • Create a folder with the same name of your package inside ~/.config/sublime-text-3/Packages.

    在~/.config/sublime-text-3/包中创建一个文件夹,其名称与包的名称相同。

  • Create inside this folder a new snippet file that will override the default package behaviour. Note that the new file should have the same name of the snippet file that you found inside the package. From console:

    在此文件夹中创建一个新的snippet文件,该文件将覆盖默认的包行为。注意,新文件的名称应该与您在包中找到的代码片段相同。从控制台:

    > cd ~/.config/sublime-text-3/Packages
    > mkdir <YOUR-PACKAGE-NAME>
    > gedit <YOUR-SNIPPET-NAME>.sublime-snippet
    
  • Put the content of your new snippet in your <YOUR-SNIPPET-NAME>.sublime-snippet. This will override the old snippet behaviour.

    将您的新代码片段的内容放入您的 .sublime-snippet中。这将覆盖旧的代码片段行为。

Sources:

来源:

#1


131  

Sublime Text 3 stores its packages in .sublime-package zip files (the location varies by OS), so unlike ST2 you can't just go to the Packages folder and see everything. However, there is an excellent plugin called PackageResourceViewer (available via Package Control) that can, among other things, extract files or whole packages to the Packages directory.

在.sublime-package zip文件中存储它的包(位置因操作系统而异),所以与ST2不同的是,您不能直接访问包文件夹并查看所有内容。但是,有一个叫做PackageResourceViewer的优秀插件(可以通过包控件获得),它可以将文件或整个包提取到包目录中。

Once you've installed the plugin:

一旦你安装了插件:

  • hit CtrlShiftP to open the command palette
  • 按下ctrl lshiftp打开命令调色板
  • type prv to get the Package Resource Viewer: options
  • 类型prv获取包资源查看器:选项。
  • select Package Resource Viewer: Open Resource
  • 选择Package Resource Viewer: Open Resource
  • navigate down the list to LaTeX
  • 导航到LaTeX列表
  • then open the section-..-(section).sublime-snippet file.
  • 然后打开部分- . .(部分)。sublime-snippet文件。

You should now be able to edit this file and save it, which will create a new file Packages/LaTeX/section-..-(section).sublime-snippet that you can open directly via the file menu if you need to alter it again.

您现在应该能够编辑这个文件并保存它,它将创建一个新的文件包/LaTeX/section-..-(section)。sublime-snippet,如果需要再次更改它,您可以通过file菜单直接打开它们。

If you'd like to work on multiple files, or an entire package, use Package Resource Viewer: Extract Package which will unzip everything into the Packages/PackageName folder. Please keep in mind, though, that once packages or individual files are extracted into the Packages folder, they overrule files of the same name located in the .sublime-package archive. This is good for customization, but if at some point the parent package is updated, you won't see the effects because they're being masked by what's in Packages. Therefore, it's probably best to extract only what you need, and keep an eye on your package updates in case new features are introduced that you want to take advantage of.

如果您想处理多个文件或整个包,请使用package Resource Viewer: Extract package,它将把所有文件解压到Packages/PackageName文件夹中。但是请记住,一旦将包或单个文件提取到包文件夹中,它们就会覆盖位于.sublime-package归档文件中的同名文件。这对于自定义很有好处,但是如果在某个时候父包被更新,您将看不到效果,因为它们被包中的内容所掩盖。因此,最好只提取您需要的内容,并关注您的包更新,以防您想要利用的新特性被引入。

Good luck!

好运!

#2


2  

To easily jump there in terminal (if you are using ST3 on OSX) is /Users/$USER/Library/Application\ Support/Sublime\ Text\ 3/Packages/User. You can see all of your snippets here and edit them as you like.

要在终端上轻松跳转(如果你在OSX上使用ST3)是/Users/$USER/Library/Application\ Support/Sublime\ Text\ 3/Packages/ USER。您可以在这里看到所有的代码片段,并按自己的喜好编辑它们。

#3


2  

In addition to the other answer, here is how to do it without having to install any additional plugin.

除了其他的答案,下面是如何在不需要安装任何额外插件的情况下完成它。

Solution not requiring any additional plugin (October 2016).


I had a similar problem while trying to override some key bindings defined in a package.

我在尝试覆盖包中定义的一些键绑定时遇到了类似的问题。

Steps

  • Install your package (using Package Manager or any other method you prefer).
  • 安装您的包(使用包管理器或您喜欢的任何其他方法)。

Your zipped package file should be now placed within the folder ~/.config/sublime-text-3/Installed Packages/<your-package>.sublime-package.

压缩包文件现在应该放在~/文件夹中。配置/ sublime-text-3 / / <包> .sublime-package安装包。

  • Check the content of the package by unzipping it (just make sure to keep the original zipped file).

    通过解压来检查包的内容(只要确保保留原来的压缩文件)。

    Among these files, find the one that contains the preference you want to edit (see Package Contents). In your case it should be a .sublime-snippet file. Remember its name.

    在这些文件中,找到包含要编辑的首选项的文件(请参阅包内容)。在您的情况下,它应该是.sublime-snippet文件。记住它的名字。

  • Create a folder with the same name of your package inside ~/.config/sublime-text-3/Packages.

    在~/.config/sublime-text-3/包中创建一个文件夹,其名称与包的名称相同。

  • Create inside this folder a new snippet file that will override the default package behaviour. Note that the new file should have the same name of the snippet file that you found inside the package. From console:

    在此文件夹中创建一个新的snippet文件,该文件将覆盖默认的包行为。注意,新文件的名称应该与您在包中找到的代码片段相同。从控制台:

    > cd ~/.config/sublime-text-3/Packages
    > mkdir <YOUR-PACKAGE-NAME>
    > gedit <YOUR-SNIPPET-NAME>.sublime-snippet
    
  • Put the content of your new snippet in your <YOUR-SNIPPET-NAME>.sublime-snippet. This will override the old snippet behaviour.

    将您的新代码片段的内容放入您的 .sublime-snippet中。这将覆盖旧的代码片段行为。

Sources:

来源: