Sublime Text can now utilize your GPU on Linux, Mac and Windows when rendering the interface. This results in a fluid UI all the way up to 8K resolutions, all while using less power than before. Regular Expressions find complex patterns in text. To take full advantage of the search and replace facilities in Sublime Text, you should at least learn the basics of regular expressions. In this guide we won't explain how to use regular expressions. The term regular expression is usually shortened to regexp or regex. Yup there's a way. Sublime Text is just a text editor like a more advanced form of Textedit on the mac. You can not compile code with it like you do in xcode. You can write it in Sublime Text and then compile it with Terminal. Mac OS X: code 'c. Sublime Text 2 stores the files in /Library/Application Support/Sublime Text 2/Settings, in the.sublimesession files that are located there. The contents of those files are a large JSON blob that contains the individual tab contents. Open up the finder. Under file open up a new finder window (CMD + N) Navigate to applications folder. Find Sublime Text and right click so you get a pulldown menu. Click on Show Package Content. Open up Content/SharedSupport/bin. Copy the subl file. Paste it in the bin folder in the usr folder we found earlier.
New instructions: https://chromium.googlesource.com/chromium/src/+/master/docs/sublime_ide.mdContents
- 9 Example plugin
Contents
- 9 Example plugin
What is Sublime Text?
- Project support.
- Theme support.
- Works on Mac, Windows and Linux.
- No need to close and re-open during a
gclient sync
. - Supports many of the great editing features found in popular IDE's like Visual Studio, Eclipse and SlickEdit.
- Doesn't go to lunch while you're typing.
- The UI and keyboard shortcuts are pretty standard (e.g. saving a file is still Ctrl+S on Windows).
- It's inexpensive and you can evaluate it (fully functional) for free.
Installing Sublime Text 2
Preferences
'tab_size': 2,
Project files
'folders':
{
}
}
'folders':
{
'name': 'src',
'*.vcproj',
'*.sln',
'*.gitmodules',
],
'build',
'third_party',
'Debug',
]
]
Navigating the project
- 'Goto Anything' or Ctrl+P is how you can quickly open a file or go to a definition of a type such as a class. Just press Ctrl+P and start typing.
- Open source/header file: If you're in a header file, press Alt+O to open up the corresponding source file and vice versa. For more similar features check out the Goto->Switch File submenu.
- 'Go to definition': Right click a symbol and select 'Navigate to Definition'. A more powerful way to navigate symbols is by using the Ctags extension and use the Ctrl+T,Ctrl+T shortcut. See the section about source code indexing below.
Enable source code indexing
- Install the Sublime Package Control package: https://packagecontrol.io/installation
- Install Exuberant Ctags and make sure that ctags is in your path: http://ctags.sourceforge.net/
- On linux you should be able to just do: sudo apt-get install ctags
- Install the Ctags plugin: Ctrl+Shift+P and type 'Package Control: Install Package'
- Create a batch file (e.g. ctags_builder.bat) that you can run either manually or automatically after you do a gclient sync:This takes a couple of minutes to run, but you can work while it is indexing.
ctags --languages=C++ --exclude=third_party --exclude=.git --exclude=build --exclude=out -R -f .tmp_tags & ctags --languages=C++ -a -R -f .tmp_tags third_partyplatformsdk_win8 & ctags --languages=C++ -a -R -f .tmp_tags third_partyWebKit & move /Y .tmp_tags .tags
- Edit the CTags.sublime-settings file for the ctags plugin so that it runs ctags with the above parameters. Note: the above is a batch file - don't simply copy all of it verbatim and paste it into the CTags settings file :-)
Windows: git config --global core.excludesfile %USERPROFILE%.gitignore
Mac, Linux: git config --global core.excludesfile ~/.gitignoreBuilding with ninja
'cmd': ['ninja', '-C', 'outDebug', 'chrome.exe'],
'file_regex': '^[./]*([a-z]?:?[w./]+)[(:]([0-9]+)[):,]([0-9]+)?[:)]?(.*)$'
Sublime Text C++ Compiler Mac
You can also add build variants so that you can also have quick access to building other targets like unit_tests or browser_tests. You build description file could look like this:
And keep using 'ctrl+b' for a regular, 'chrome.exe' build. Enjoy!
Example plugin
import subprocess
class RunLintCommand(sublime_plugin.TextCommand):
command = ['cpplint.bat', self.view.file_name()]
stdout=subprocess.PIPE,
print process.communicate()[1]
{
}
D:srccgitsrccontentbrowserbrowsing_instance.cc:69: Add #include <string> for string [build/include_what_you_use] [4]
Done processing D:srccgitsrccontentbrowserbrowsing_instance.cc
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__len__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'add_regions', 'begin_edit', 'buffer_id', 'classify', 'command_history', 'em_width', 'encoding', 'end_edit', 'erase', 'erase_regions', 'erase_status', 'extract_completions', 'extract_scope', ... <snip>
Compile current file using Ninja
As a more complex plug in example, look at the attached python file: compile_current_file.py. This plugin will compile the current file with Ninja, so will start by making sure that all this file's project depends on has been built before, and then build only that file.
First, it confirms that the file is indeed part of the current project (by making sure it's under the <project_root> folder, which is taken from the self.view.window().folders() array, the first one seems to always be the project folder when one is loaded). Then it looks for the file in all the .ninja build files under the <project_root>out<target_build>, where <target_build> must be specified as an argument to the compile_current_file command. Using the proper target for this file compilation, it starts Ninja from a background thread and send the results to the output.exec panel (the same one used by the build system of Sublime Text 2). So you can use key bindings like these two, to build the current file in either Debug or Release mode:
{ 'keys': ['ctrl+f7'], 'command': 'compile_current_file', 'args': {'target_build': 'Debug'} },
{ 'keys': ['ctrl+shift+f7'], 'command': 'compile_current_file', 'args': {'target_build': 'Release'} },
If you are having trouble with this plugin, you can set the python logging level to DEBUG in the console and see some debug output.
Format selection (or area around cursor) using clang-format
Miscellaneous tips
- To synchronize the project sidebar with the currently open file, right click in the text editor and select 'Reveal in Side Bar'. Alternatively you can install the SyncedSideBar sublime package (via the Package Manager) to have this happen automatically like in Eclipse.
- If you're used to hitting a key combination to trigger a build (e.g. Ctrl+Shift+B in Visual Studio) and would like to continue to do so, add this to your Preferences->Key Bindings - User file:
- { 'keys': ['ctrl+shift+b'], 'command': 'show_panel', 'args': {'panel': 'output.exec'} }
- Install the Open-Include plugin (Ctrl+Shift+P, type:'Install Package', type:'Open Include'). Then just put your cursor inside an #include path, hit Alt+D and voila, you're there.
- If you want to take that a step further, add an entry to the right-click context menu by creating a text file named 'context.sublime-menu' under '%APPDATA%Sublime Text 2PackagesUser' with the following content:
[ { 'command': 'open_include', 'caption': 'Open Include' } ]
- Open Command Palette (Ctrl-Shift-P)
- Type 'Package Control: Install Package' (note: given ST's string match is amazing you can just type something like 'instp' and it will find it :-)).
- Case Conversion (automatically swap casing of selected text -- works marvel with multi-select -- go from a kConstantNames to ENUM_NAMES in seconds)
- CTags (see detailed setup info above).
- Git
- Open-Include
- Text Pastry (insert incremental number sequences with multi-select, etc.)
- Wrap Plus (auto-wrap a comment block to 80 columns with Alt-Q)
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:
Sublime Text C++ Ide
- 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.
- Press Ctrl + ` to call up the console
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())
Restart Subl
- 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
Sublime Text 4 Download
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.
C Compiler For Sublime Text
Well, that’s it. I’ll continue to add if there’s anything else in the future.