Uncrustify
A source code beautifier/formatter plugin that allows the user to use Uncrustify to format the C-like languages in Sublime Text.
Details
Installs
- Total 3K
- Win 1K
- Mac 694
- Linux 809
Apr 27 | Apr 26 | Apr 25 | Apr 24 | Apr 23 | Apr 22 | Apr 21 | Apr 20 | Apr 19 | Apr 18 | Apr 17 | Apr 16 | Apr 15 | Apr 14 | Apr 13 | Apr 12 | Apr 11 | Apr 10 | Apr 9 | Apr 8 | Apr 7 | Apr 6 | Apr 5 | Apr 4 | Apr 3 | Apr 2 | Apr 1 | Mar 31 | Mar 30 | Mar 29 | Mar 28 | Mar 27 | Mar 26 | Mar 25 | Mar 24 | Mar 23 | Mar 22 | Mar 21 | Mar 20 | Mar 19 | Mar 18 | Mar 17 | Mar 16 | Mar 15 | Mar 14 | Mar 13 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 3 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Readme
- Source
- raw.githubusercontent.com
Sublime-Uncrustify
This is a source code beautifier/formatter plugin that allows the user to use Uncrustify(1) to format the C-like languages in Sublime Text.
Sublime-Uncrustify can setup to read different configures (as different code styles) according to the languages and filenames or projects.
NOTE: (1) Uncrustify is a source code beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA.
Screenshot
Install
An Uncrustify MUST be installed before Sublime-Uncrustify can work.
- An Win32 binary is available in Sourceforge.
- OSX can install via 'brew install uncrustify' by Homebrew or 'port install uncrustify' by MacPorts.
- Other Linux-like OS please see http://uncrustify.sourceforge.net/ or build the program yourself.
Remember the path of your Uncrustify executable (for step 4.2).
Configuring the Uncrustify:
Examine the example config files in Uncrustify/etc (from uncrustify source) or Uncrustify/cfg (from Win32 pre-built).
or you can find in:
http://sourceforge.net/p/uncrustify/code/ci/master/tree/etc/
Copy the existing config file that closely matches your style and modify(2) as your version.
Remember the path of your config file for uncrustify (for step 4.3).
NOTE: (2) See 'Other Uncrustify Utilities' below…
Install the Sublime-Uncrustify:
The preferred method is to use the Sublime package manager Package Control:
[sublime text menu]->[Preferences]->[Package Control]->[Install Package]->Search “Uncrustify” and install.
Alternatively, the files can be obtained on GitHub:
https://github.com/obxyann/Sublime-Uncrustify
Just create a new folder named Uncrustify under your Sublime Text Packages folder and copy the files into.
Configure the Sublime-Uncrustify:
[sublime text menu]->[Preferences]->[Package Settings]->[Uncrustify]
- Copy the default settings as user settings.
- Specify the path to uncrustify executable…(where step 1 installed)
- Specify the config file for uncrustify…(where step 2 copied and modified)
- Add your rules to use different config files (code styles) according to the languages and filenames.
Usage
NOTE: Although it can UNDO after a format action, please backup/SAVE your important/unsaved file before using!
Format whole document:
Current document
[sublime text menu]->[Tools]->[Uncrustify]->[Format Document]
Format a selection:
Make a selection then
[sublime text menu]->[Tools]->[Uncrustify]->[Format Selection]
Undo formatted:
Just Undo before exit.
You can edit the Uncrustify config file specified in settings:
[sublime text menu]->[Preferences]->[Package Settings]->[Uncrustify]
->[Open Uncrustify Config - Default]
for all languages/file types supported and no custom filter or language matched
->[Open Uncrustify Config - Matches Current Document]
according to current document matches one of filters or languages…
Notices
Some languages/file types don't supported by Uncrustify will pop a warning.
Currently only supports C, C++, D, C#, Java, Pawn, Objective C, Objective C++, Vala, SQL and ECMA.
This is my first Python program. Before I have no knowledge about Python. So I must warn again…
It is not guaranteed to work perfectly, please backup/SAVE your important/unsaved file before using!
Only tested in Windows 7 + Sublime Text 2/3. Please help to improve this plugin if it don't work in your OS!
License
Uncrustify is GPL V2 belongs to its authors. (Uncrustify binary not include in Sublime-Uncrustify)
Sublime-Uncrustify is released under the MIT license.
Other Uncrustify Utilities
You can change your Uncrusify config file easily by:
(WIN32) UniversalIndentGUI: http://universalindent.sourceforge.net/
(OSX) UncrustifyX: https://github.com/ryanmaxwell/UncrustifyX/
But I think the default config file default.cfg from Uncrusify is well documented to modify directly!