[Solved] How do you give plain text files a default?

Discuss the word processor
Post Reply
cobbhen
Posts: 2
Joined: Thu Jun 14, 2018 10:05 pm

[Solved] How do you give plain text files a default?

Post by cobbhen »

One of the uses I have found for OO is as an editor for assembly language programs. The source file must be a "clean" text file ... i.e no embedded format control characters. I have figured out what font(s), tab settings, etc. I need to use in order to obtain a display (and listing) of the source file that is "field aligned" vertically (this really helps when you attempting to debug a program, using the source listing. The problem I'm running in to is that when I open a source code file (right now, I'm using .txt extension) OO defaults to "Preformatted text". I must then go through the procedure of selecting the entire text and clicking on the "default" format selection. When I'm done with file, it is saved. I have to go through this procedure each time I open the file.

Is there a way to (template, etc.) to make OO "remember" what the format needs to be so I can avoid these steps?

Thanks,
--HCC
Last edited by cobbhen on Fri Sep 07, 2018 10:28 pm, edited 1 time in total.
OpenOffice 4.1.4
Win7 SP1
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: How do you give plain text files a default opening forma

Post by RoryOF »

Yes, you can set a default template, with default styles. See
[Tutorial] Creating a new default template

but, to be frank, I think you would be better choosing either a programming editor or an IDE. Which to choose? I cannot advise, as I do very little programming now.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: How do you give plain text files a default opening forma

Post by John_Ha »

A .txt file is a flat ASCII file containing only characters - it does not (and cannot) save any formatting information - not even the font or font size.
test.txt file containing abcde opened in a Hex editor
test.txt file containing abcde opened in a Hex editor
You must save the file as a .odt to keep any formatting.

You could record a macro which selects All and formats it. Place an icon for the macro on the toolbar. Open a .TXT file and click the icon - all done in one click and it still leaves AOO as standard for other uses.

You would be much better using a proper software editor (google for options) which lays out the language you are using. Have a look at Notepad++ where you can use pre-defined formats or define your own. It does useful things like automatic indenting, identifying matching start and end tags in XML, pretty printing XML, finding matching start and end brackets etc.
Clipboard03.gif
Clipboard01.gif
Showing that a problem has been solved helps others searching so, if your problem is now solved, please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How do you give plain text files a default opening forma

Post by Villeroy »

Bind a custom keyboard shortcut or some toolbar button to character style "Source Text". Mine is Ctrl+9. Ctrl+0 is for text body, Ctrl+1 to 5 are for different levels of column headers.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply