2

I want to change up my for loop snippets in Sublimetext 3.

One example is the forv for vector loop. I'd like to have that use an auto iterator instead of a vector iterator, as I often use std::array.

But I can't find these snippets anywhere, or where to edit them.

1 Answer 1

2

Best practice is overriding snippets. Create a snippet with the same name as you want to override and save it to User packages directory. Details are given here. Most easy way to find User packages directory is Browse Packages Menu Option. It will show you the directory where user packages saved.

I looked at where sublime installed and found C++.package file (MacOS /Applications/Sublime Text.app/Contents/MacOS/Packages\C++.sublime-package) . I unarchived it and found snippets.

Your snippet is following

<snippet>
    <description>Vector For Loop</description>
    <content><![CDATA[for (std::vector<$1>::iterator ${3:i} = $2.begin(); $3 != $2.end(); ++$3)
{
    $0
}]]></content>
    <tabTrigger>forv</tabTrigger>
    <scope>source.c, source.objc, source.c++, source.objc++</scope>
</snippet>

Create New snippet and copy paste this code. Change it according to your tastes. Save it to default snippet directory.

Sign up to request clarification or add additional context in comments.

1 Comment

You can use sublime.wbond.net/packages/PackageResourceViewer to view packaged files. Saving them will place the override in the proper location. It's a plugin I wrote, but I feel it saves some trouble of finding/extracting packages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.