Some plug-in configurations for sublime text 2 (MacOSX)

Time:2021-8-31

Sublime Text 2(Hereinafter referred to as Subl)Is a very powerful cross platform code editor. It needs some configuration to make it more powerful.
The configurations involved in this article are as follows:

  • Set Subl to support command line startup
  • Install package control to enable the Subl to support the installation of plug-ins
  • Install ctags and ctags plug-in to make Subl support function definition jump

Next, let’s introduce them one by one.

Set Subl to support command line startup

Subl is easy to use, but no matter how easy an editor is, if it does not support starting from the command line, it is basically useless for programmers, especially under Mac and Linux.
In fact, Subl already contains a command-line tool called Subl (it’s not abbreviated here, it’s really called Subl), which is installed in the following directory with the program

~/bin/subl

However, this tool does not establish a symbolic link to the Subl program, so running this program cannot open the Subl program. You need to execute the following command to establish a symbolic link.

ln -s “/Applications/Sublime Text\ 2.app/Contents/SharedSupport/bin/subl” ~/bin/subl

So you can call the Subl from the command line. This method comes from the official website of Subl. If I don’t speak clearly, you can see the original text,The original address is here
Example: if test. C exists, open test. C. if it does not exist, create a test. C open in the buffer

subl text.c

Example: open SRC folder

subl src

If you are prompted that the Subl cannot be found, you can echo $path to see if ~ / bin is not included in the environment variable. If not, open ~ /. Bash_ Profile, enter:

export PATH=~/bin:$PATH

After completing the configuration of command line startup, Subl is a great code editor.

Install package control

Package control is the plug-in manager of Subl. For Subl, it is equivalent to brew under Mac, yum and apt get under Linux.
The way it is installed feels a little geek.

  1. Press Ctrl + ` to call up the console
  2. Paste the following Python script into the bottom input box and press enter

    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(‘http://sublime.wbond.net/‘+pf.replace(‘ ‘,’%20’)).read())

  3. Restart Subl

  4. Press Shift + CMD + P to call up the command box and enter install. You can see the package control: install package option in the drop-down box, indicating that the installation is OK

Install ctags and ctags plug-ins

After having package control, it is very easy to install ctags plug-in. Just press Shift + CMD + P to call up the command box, enter install to find the package control: install package option, and press enter. After a while, a search box will pop up, fill in ctags, find ctags, and press enter to install it.

The ctags plug-in is installed, but it will take a lot of trouble to install ctags. First install the package manager brew.
The installation method is to enter the following commands on the command line. Be careful not to bring sudo

ruby -e “$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)”

After installation, enter brew doctor as prompted to check the environment and solve the prompted alarm. In particular, we need to solve the problem that / usr / local / bin is not in the front of the path. Otherwise, we may run ctags installed with brew instead of the system itself.
After everything is done, you can install ctags.

brew install ctags

After installation, you can enter the SRC directory where the source code is located and execute

ctags -R -f .tags

Then open the directory with Subl

subl src

At this time, you can move the cursor over the function name, press Shift + Ctrl +. To jump to the definition, and press Shift + Ctrl + to jump back.

Well, that’s it. I’ll continue to add if there’s anything else in the future.

Recommended Today

Supervisor

Supervisor [note] Supervisor – H view supervisor command help Supervisorctl – H view supervisorctl command help Supervisorctl help view the action command of supervisorctl Supervisorctl help any action to view the use of this action 1. Introduction Supervisor is a process control system. Generally speaking, it can monitor your process. If the process exits abnormally, […]