我经常使用Geany文本编辑器来编写程序代码。我最近知道,我们可以使用一些键绑定将代码段自动插入Geany中,我很喜欢这样的想法。
因此,我在《 Geany》手册中介绍了一些片段的基础知识。
我尝试这样做:一个Octave脚本的必需代码段是:
#!/usr/bin/octave -qf
% Author : Bhishan Poudel
% Date :
I_like_this_to_be_inserted_automatically
到目前为止,我的尝试:
我们必须编辑名为“ snippets.conf”的配置文件,可以像这样访问:
菜单工具→配置文件→ snippets.conf
或者~/.config/geany/snippets.conf
。
然后,我首先检查了Octave脚本的文件类型:
geany --ft-names
我看到的文件类型是[Matlab/Octave]
。因此,我在其中添加了以下代码。
[Matlab/Octave]
pre=#!/usr/bin/octave -qf \n% Author : Bhishan Poudel \n% Date : {date}\n\n
注意:要查找八度安装目录的shebang路径,请键入 which octave
然后,为实现代码,我创建了一个名为的文件a.m
,并在Geany中将其打开。然后尝试此代码段的命令是* pre Tab(类型,pre
后跟Tab),然后输出是:
#!/usr/bin/octave -qf
% Author : Bhishan Poudel
% Date : 2016-05-23
如何将日期格式更改为2016年5月23日?
一些有用的链接如下:http :
//www.geany.org/manual/0.18.1/index.html#user-definable-snippets
一种方法是使用{command: date}
date的默认命令行语法。因此,就您而言,我认为这将是
{command:date +"%b %d, %Y"}
结果在这里变成:
$ LANG=C date +"%b %d, %Y"
May 24, 2016
另一种更通用的方法是为Octave脚本设置模板。在模板内部,您应该能够根据Geany的配置插入值。看一下手册,但是像这样保存为模板的东西可能会起作用(未经测试):
#!/usr/bin/octave -qf
% Author : {developer} <{mail}>
% Date : {date}
但是您需要在Geany的首选项中配置日期格式-在这里您可以使用上面的选项。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句