I often use the Geany text editor to write programming code. I recently knew that we can insert a code snippet in Geany automatically using some keybindings and I liked the idea of that.
So, I went through some of the basics of the snippets in the Geany manual.
And I tried to do this: A required snippet for an Octave script is:
#!/usr/bin/octave -qf
% Author : Bhishan Poudel
% Date :
I_like_this_to_be_inserted_automatically
My attempt so far:
We have to edit the configuration file called "snippets.conf" which can be accessed like this:
Menu Tools → Configuration Files → snippets.conf
Or ~/.config/geany/snippets.conf.
Then, I first checked the file type for Octave scripts:
geany --ft-names
I see the filetype is [Matlab/Octave]. So, I added the following code there.
[Matlab/Octave]
pre=#!/usr/bin/octave -qf \n% Author : Bhishan Poudel \n% Date : {date}\n\n
Note: to find the shebang path for octave installation directory, type which octave
Then to implement the code I created a file called a.m and opened it in Geany. Then the command to try this snippet is *preTab (type pre followed by Tab) then the output is:
#!/usr/bin/octave -qf
% Author : Bhishan Poudel
% Date : 2016-05-23
How can we change the date format to May 23, 2016?
Some useful links are following:
http://www.geany.org/manual/0.18.1/index.html#user-definable-snippets