ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Cpp​Toolkit

by mccartnm ST3

Sublime Text 3+ plugin to make C++ life a little easier

Details

Installs

  • Total 3K
  • Win 2K
  • Mac 362
  • Linux 890
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 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6
Windows 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 3 0 0 0 0 0 1 0 3 0 3 1 1 0 0 0 0 0 1 1 0 0 0 1 0 1 0
Mac 0 0 0 0 0 0 1 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
Linux 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 2

Readme

Source
raw.​githubusercontent.​com

Cpp Toolkit

A collection of utilities for managing C++ code implementation.

Disclaimer: Sublime is not a fully featured C++ IDE and this plugin doesn't try to make it one. It simply tries to speed up your usual work

Features

  • Build Implementation from the class definition
  • Generate get/set commands for internal members
  • Move implementations outside of the class definition
  • (Coming soon) Build implementations for an entire class

Quick Tour

Auto Implement

Many IDEs out there make use their inherent understanding of you project through syntax and preprocessing to present perks like being able to automatically declare methods from the header within the source. This saves the developer loads of time.

Usability

Getter / Setter Functions

Getters and setters are used in a plentiful sense in modern C++. For this reason, there is also the ability to right click on members and build their respective functions.

Currently this does its best to identify the proper signature but may not always be what you're looking for. That said it should still speed up Sublime typing.

GetAndSet

A Scenario

Let's say you have the header:

// my_file.h
namespace my_namespace
{

class MyClass : public SomeBase
{
public:
    // ...

    void getSomeData(float bar, MyStruct::SomeEnum val = MyStruct::Value) const override;
}

And now you want to move that to your source. Currently in Sublime you have a limited set of options. Until this plugin I would do the following:

  1. Move my cursor to the line and hit Ctrl + C to copy the whole line
    • If the definition was multiple lines, I would use Ctrl + L enough times to get it all or use my mouse
  2. Swap to the source with Alt + O
  3. Move my cursor to where I could declare the method
  4. Paste in the header code via Ctrl + V
  5. Highlight the line (or just have one cursor on it if one line) and Shift + Tab enough to set it
  6. Fill in the ownership chain
  7. Die a little inside
  8. Go throughout the function and remove any cruft like override; and the = MyStrcut::Value in the example above
  9. Finally add the parentheses and get to freaking work

The Fix

With Cpp Toolkit, the workflow is:

  1. Right click on the function name to declare
  2. Go to C++ Toolkit > Declare in <source_file_name>.cpp

And bam! You'll be moved to the source file, all the right guts and ownership will be filled in, no pesky non-const classifiers or default values, and your cursor will be right where you need it to start typing the function body!

Note: At the moment, this assumes, just like the Alt + O shortcut, that the header and implementation are next to each other in the filesystem. In the future I may add ways to declare an implementation root or location or some such.

The Catch

Ultimately, this tool is parsing the file and doing what it can with immediate information but, as any C++ developer knows, the language has quite a few caveats so you may not get the perfect signature or ownership every time however it should still get you moving in the right direction and speed up a lot of typing.

Install

Using Package Control Sublime Package Manager

To install use these commands.

  • Hit Ctrl + Shift + P
  • Type install and select Package Control: Install Package
  • Type CppToolkit and select CppToolkit

Or just clone this repo and place it into your Sublime user data directory under Packages.

Roadmap

There are many things to do for this plugin that I'm hoping to tick away at in my spare time

  1. Basic preprocess for things like #ifdef 0 ... #endif clauses
  2. Camel case/Snake case conversion when needed This is already in the sweet CaseConversion plugin
  3. Switch statement breakout (based on some kind of classifier)
  4. Smart inject based on other declarations in the source rather than always at the end
  5. Reverse implement to go from source to header under a given privilege
  6. Apply changes to function signatures in both header and source
  7. Getter/Setter functions of members (done)
  8. Have the commands work in both source and header, just using the parser to understand what commands can be used
  9. Hotkeys for select functions
  10. Implement a whole class by simply right clicking on the class name (woah)