I tried opening Tools-> configuration file -> snippets.conf and edited [c++] block
#~ [C++]
#~ cout=cout<<%cursor%<<endl;
#~ if=if (%cursor%)%block_cursor%
#~ else=else%block_cursor%
#~ for=for (int i = 0; i < %cursor%; i++)%brace_open%\n%brace_close%
#~ while=while (%cursor%)%block_cursor%
#~ do=do\n{\n\t%cursor%\n} while (%cursor%)\n
#~ switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
#~ try=try%block%\ncatch (%cursor%)%block_curso
I added line#~ cout=cout<<(cursor%)<<endl;
then restarted my computer and geany multiple times it neither gave me error nor gave extension in FileName.cpp . When i type cout it gave normal tab not extension i added.
After fiddling with snippet.conf
for a half hour or so, I stumbled on the rather annoying answer...
The #
characters at the beginning of lines in snippet.conf
are comment characters, and the ~
characters are apparently just there to confuse everybody. So for a snippet to work, both the section heading (e.g. [C++]
) and the snippet definition should be flush left without the leading #~
. Leading spaces work, but in that case syntax highlighting of the line in snippet.conf
won't be shown, so it's best to just make things flush left.
Also, after adding a new snippet, there's no need to restart either your computer, geany, or even the document you want to use it in. A new snippet should be available as soon as snippet.conf
is saved.
And what about all of the commented-out lines in snippet.conf
? They apparently don't do anything as they are. However, they can be used to override geany's default snippet functionality by removing the #~
characters from the appropriate section heading and snippet lines and then making changes as needed.