██████╗ ███████╗████████╗ ███████╗███████╗████████╗
██╔════╝ ██╔════╝╚══██╔══╝ ██╔════╝██╔════╝╚══██╔══╝
██║ ███╗█████╗ ██║ ███████╗█████╗ ██║
██║ ██║██╔══╝ ██║ ╚════██║██╔══╝ ██║
╚██████╔╝███████╗ ██║ ███████║███████╗ ██║
╚═════╝ ╚══════╝ ╚═╝ ╚══════╝╚══════╝ ╚═╝
+ + + +
A VS Code extension that auto-generates idiomatic C++ getters and setters and inserts them directly into your paired .hpp and .cpp files. No more boilerplate.
From the Marketplace:
- Install from the VS Code Marketplace
- Or from inside VS Code: open Extensions (
Ctrl+Shift+X/Cmd+Shift+X), searchget-set-plus-plus, click Install.
- Auto-detects the enclosing class name — scans backwards from your selection, handles
class Foo,class Foo final,class Foo : public Bar, private Baz, and multi-line declarations. Falls back to a validated input box if it can't find one. - Inserts directly into your files — adds declarations into the
.hppafter your selection, and definitions into the paired.cpp(auto-finds.cpp/.cc/.cxx, with a quick-pick menu if multiple match). Preview-in-new-tab mode is also available. - Broad type support:
- All primitives (
int,double,float,char,bool,long,short,size_t, fixed-width ints likeuint32_t, unsigned variants,long long,long double) std::string— returned asconst std::string&(correct C++ practice)- Template types (
std::vector<T>, nested templates likestd::map<std::string, int>) - Raw pointers (
Foo*,int*— also normalizesint *ptrsyntax) - Custom object types — returned as
const T&
- All primitives (
constmember handling — generates only the getter, no setter (sinceconstmembers can't be reassigned).- Skips access specifiers, qualifiers, and initializers —
public:,private:,static,mutable,volatile,inline,explicit, and default initializers (int x = 5;) are stripped automatically. boolnaming conventions — fields starting withis/hasskip thegetprefix (e.g.bool isAlive→bool isAlive(), notgetIsAlive()).- Duplicate detection — scans existing methods in the file and skips fields whose getter/setter already exists. Safe to re-run on the same selection.
- Keybinding —
Ctrl+Shift+G/Cmd+Shift+Gtriggers generation when an editor is focused.
- Open a
.hppfile containing a class. - Select one or more member variable lines (e.g.
int age;,std::string name;,std::vector<int> inventory;). - Press
Ctrl+Shift+G(Cmd+Shift+Gon Mac), or open the Command Palette and run Get Set ++: Generate Getters and Setters. - Choose Insert into files (writes declarations into the
.hppand definitions into the paired.cpp) or Preview in new tab (shows the generated code without modifying anything).
Select these lines in your Player.hpp:
int health;
std::string name;
const int maxHealth;
std::vector<int> inventory;Generated .hpp insertion:
int getHealth() const;
void setHealth(int health);
const std::string& getName() const;
void setName(const std::string& name);
int getMaxHealth() const;
const std::vector<int>& getInventory() const;
void setInventory(const std::vector<int>& inventory);Generated .cpp insertion:
int Player::getHealth() const {
return health;
}
void Player::setHealth(int health) {
this->health = health;
}
// ... (and so on for the rest)No configuration required.
- References (
Foo&) are not currently supported as field types. - The
.cppdefinitions are appended to the end of the file — if your file ends inside a namespace block, you may need to move the inserted code inside it. - Generated declarations are inserted using the access modifier currently in effect at your selection point. If you select fields in a
private:block, the auto-generated methods land inprivate:too — add apublic:line above your selection if needed.
Issues and PRs welcome at the GitHub repo. The codebase is split into src/utils.ts (pure logic, fully unit-tested) and src/extension.ts (VS Code integration), so most contributions can be tested without spinning up an extension host.
- Direct file insertion into paired
.hppand.cpp(with.cc/.cxxfallback and quick-pick for multiple matches) - Full template-type, pointer, and custom-object support
constmember handling (getter-only generation)- Duplicate detection — re-running on the same selection skips already-generated methods
- Strips access specifiers,
static,mutable,volatile,inline,explicit, and default initializers - Keybinding:
Ctrl+Shift+G/Cmd+Shift+G - Refactored into testable architecture (
utils.ts/extension.ts) with 70+ unit tests
- Automatic class name detection (scans backwards from selection)
- Input box fallback when class cannot be detected
- Initial release: basic getter/setter generation for primitive types