Вопрос

I have used Geany4Windows for a long while but am still confused how it handles editing text files and I decided to ask for help now!

If I open a new file from menu I can type plain text in it and yet when I save the file it does not give a .txt extension option to save as and while I can add this to the end of the name I give to the file and save it and it saves as a .txt file with no problem. If instead, I do not do this and leave off the file extension, and then save it, it saves as a file with no extension!

There is an option to open a new template file but in my Geany4Windows there is no .txt template. I tried making my own by making a file with a {fileheader} and saving it in C:\Program Files (x86)\Geany\data\templates\files as file.txt.

This does then give me the option to open a new template text file but when I save that the text fileheader produces this:

 /*
 * mynewdefaulttexttemplateGeany.txt.txt
 * 
 * Copyright 2014 Richard <Richard@RPDHPI5PAVILION>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 * 
 * 
 */My first text file from new text template I just created in Geany.....

The file header shows as >> mynewdefaulttexttemplateGeany.txt.txt << with a double .txt extension.

If I could fix this file header for my default template file.txt file (so it doesn't save with the extension added twice), I would be happier working with plain text files in Geany4Windows! Anyone know how I can fix this please? Thanks.

MY EDIT I have fixed this now and it was helped by Matthews post below (& see my comment on that). To recap the solution: I made a new custom file type file.txt with {fileheader} To make this work I added the line txt=*.txt to filetype_extensions.conf Also I created filetypes.txt.conf and added..

[settings] extension=txt lexer_filetype=C [styling=C] # multiline comments comment_open=/* comment_close=*/

This works now! See screenshots before & after: Geany editor with custom .txt file and fileheader extension issue & not in red text as default

after: Geany editor with custom .txt file and fileheader now working correctly as default

I do like Geany4Windows but it can be interesting trying to customise it to use new filetypes etc etc. Happy coding & editing with Geany on Windows & Linux (does it run on Mac?!). I'm pleased this is fixed now. :-)

Это было полезно?

Решение

You could create a file named like filetypes.Text.conf and inside of it put:

[settings]
extension=txt

Then add it to filetype_extensions.conf [Extensions] section like:

...
Text=*.txt;*.text; etc...
...

The manual has more details about custom filetypes.

Другие советы

You can create a *.txt-file by saving your file like foo.txt or baa.txt. Plain text not necessarily having txt-extension.

To explain Matthews answer more, you have been using filetype None, which does not have an extension. By creating the filetype Geany now knows about files with extension .txt

BTW you can edit filetype_extensions.conf by menu->tools->configuration files-> filetype_extensions.conf.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top