131

I used to create new blank files in Nautilus (Files) using the right click context menu. It really saved me a lot of time. Since Nautilus 3.6, there is no such entry.

Is there a way to create a new blank file in Nautilus 3.6 and above?

Braiam
  • 67,791
  • 32
  • 179
  • 269
remjg
  • 3,663
  • A new file? A blank text file? Just run gedit & in terminal, write stuff in it and Ctrl+S to save. If you want to get feisty, in the terminal, type vim which is a lot more complicated than gedit. Terminal-> Ctrl +Alt+T – dearN Oct 29 '12 at 17:12
  • 13
    As I wrote below, what I want to do is not to lose time while looking for the folder I'm working in. I could use a terminal but I still have to change directory (using cd). I could use gedit, but I will have to go manually to the folder where I want to create my new file. – remjg Oct 29 '12 at 17:42
  • I don't see the problem. You can still save your file wherever you want? – dearN Oct 29 '12 at 17:43
  • 9
    I have a very complex folder organization which makes finding my current folder painful. For example, let's say I want to write a new LaTeX report at "~/Documents/University/Master/CourseX/ProjectY/Report/". I'll have to open Latexila/gedit, create a new file, select this folder after going through every parent folder and save it... Before I use to create my "Report" folder, a new blank file, rename it with .tex extension and that was it. – remjg Oct 29 '12 at 17:54
  • 2
    Oh... tell me about it! :P Just finishing my dissertation...What I actually do in that case is export curv=/home/username/Research/Dissertation/Draft/Curvature_effects/dftdata and then cd to say $curv and so on. I save all these file paths in a text file. You could perhaps put them in your .bashrc file (I've done that as well). Does save time... – dearN Oct 29 '12 at 17:59
  • Also, do you use gnome-panel? IF you don't you'll like it if you liked the clean no complications look of linux pre Ubuntu 11.04. – dearN Oct 29 '12 at 18:00
  • That's a great idea ! But since I always have nautilus opened at this location, I could use nautilus-open-terminal to jump to the right location. But I would never have thought of it, I keep it in mind ! – remjg Oct 29 '12 at 18:06
  • 1
    I use gnome-shell, I must say I'm quite satisfied with it. I had to learn how to use it, but I'm very efficient now (the Desktop Scroller extension helps switching workspaces quickly). – remjg Oct 29 '12 at 18:09

10 Answers10

182

Well, I filled a bug report on bugzilla.gnome.org and I feel stupid now... This feature still exists.

The solution is to create a blank file named for instance new inside the ~/Templates/ folder of your home directory.

On non-English installations, the templates directory might have another name. One can find the actual directory with xdg-user-dir TEMPLATES.

Creation of a new template file


If you're still facing the problem, Check the file in ~/.config/user-dirs.dirs if XDG_TEMPLATES_DIR variable is set correctly. If it is set to $HOME/ instead of $HOME/Templates/, correct and save that file.

Ola
  • 758
remjg
  • 3,663
  • This didn't work for me in Nautilus 3.6.3 – szx Dec 26 '12 at 00:36
  • Strange, I've the same version as you. Maybe your Templates/ directory doesn't have the same name due to localisation settings ? – remjg Dec 26 '12 at 14:31
  • No, the name is OK (I'm using English/US locale) – szx Dec 26 '12 at 15:05
  • 13
    Turns out this was caused by the XDG_TEMPLATE_DIR variable in ~/.config/user-dirs.dirs being set to $HOME rather than $HOME/Templates. – szx Jan 11 '13 at 09:03
  • Glad to know you found a solution to your problem! – remjg Jan 15 '13 at 16:02
  • 7
    @remjg But do you know why there's no New document menu at all when the Templates folder contains no files even though a possibility of creating an Empty document clearly exists (the last position in above mentioned context menu)? – cprn Feb 03 '13 at 01:04
  • 2
    The "Empty document" entry is a bug and has been removed since (see the bug report), that was indeed non consistent! – remjg Feb 04 '13 at 23:38
  • This still fixes the mentioned (weird) behaviour on:

    Linux marcopc 3.13.8-1-ARCH #1 SMP PREEMPT Tue Apr 1 12:19:51 CEST 2014 x86_64 GNU/Linux +++ GNOME nautilus 3.10.1 +++ GNOME Shell 3.10.4

    – GorillaMoe Apr 25 '14 at 10:44
  • 9
    Somewhat of a paradoxical problem - can't create a new document unless you create a new document. – Enigma Feb 26 '15 at 23:52
  • 10
    WOW.

    This is... A really bad user experience.

    Where can one submit a patch to always put a new text file in there. Or, even better, a new file that contains instructions on how to add new files to the New Documents tab?

    – Ajax Dec 19 '15 at 05:29
  • 5
    This is horrible. You shouldn't need a user-visible random directory in your home for every application that wants to store some config. I had naturally deleted that directory altogether. – Shahbaz Apr 24 '17 at 02:46
  • 1
    I for one think this feature looks great, very flexible! Also really cool that this can be made user dependent and detached from installed apps cluttering it at their whim. But yes, the weakness is that there is no good user interface for it. Since an empty text file is per definition a zero byte file and a super common file type, that should be there by default, followed by something like a menu item separator and "Manage templates..." – Jonas Apr 30 '17 at 11:41
  • 2
    Chicken & the Egg problem. I want to use Nautilus to create a new file in the Templates directory – Jonathan Apr 07 '18 at 17:27
  • 1
    Just adding two comments for complete idiots like me. If you changed the template directory in ~/.config/user-dirs.dirs you need to restart the pc for it to take effect. To create the first text file go to the template directory right click, select "open in terminal" then use touch 'new.txt' to create the text file (see also other answers). – Kvothe May 02 '18 at 10:26
  • 1
    If the New document's contextual menu don't appear, restart Nautilus by typing "nautilus -q" or "killall nautilus" in a terminal. – Stéphane B. Aug 26 '18 at 10:33
26

Just create some file templates in your home Templates directory:

XDG_TEMPLATES_DIR=$(xdg-user-dir TEMPLATES)
cd "$XDG_TEMPLATES_DIR"
touch 'New Text File.txt' && touch 'New Word File.doc' && touch 'New Excel Spreadsheet.xls'

Go to any folder then, right click and you will see the "New Document" option with the templates you created.

muru
  • 197,895
  • 55
  • 485
  • 740
Calin Rusu
  • 261
  • 3
  • 2
  • 1
    So I went into my home templates directory with Nautilus and, lo and behold, I couldn't create a file there because there were no templates there to allow me to create new files. Man, am I glad I switched to Nemo at home, the Nautilus people first took away multi-column file list and now this. I can only assume they hate humanity :-) Oh well, back to the command line. Still, thanks for letting me know what to change, the brain-deadedness of Nautilus developers is not your fault. –  Feb 12 '16 at 06:19
  • 3
    If the New document's contextual menu don't appear, restart Nautilus by typing "nautilus -q" or "killall nautilus" in a terminal. – Stéphane B. Aug 26 '18 at 10:33
  • Just a note for anybody who has no Templates directory in their home folder. Just created it then open .config/user-dirs.dirs file check all the files match, You should see stylised Icon's in your home folder if they are correct instead of a standard looking folder but its worth checking. In mine the templates line pointed at $HOME so the templates were not picked up. nautilus -q was also needed, thank you @Stephane B – CodingInTheUK Aug 21 '21 at 22:12
  • Super!!!! Thanks – cloud81 Dec 23 '22 at 10:07
  • Wouldn't want to create a new Word document and then save that in the Templates directory, rather than creating an invalid Word document which is zero bytes long? – Flimm Dec 15 '23 at 17:42
5

The name of the file must be Untitled Document In Ubuntu 20.04

touch ~/Templates/Untitled\ Document

This works for me

4

I can't really find this option in 3.6 either, but there are command line tools that can help you out (but it depends on what you are actually trying to accomplish here).

In a Terminal (CTRL+ALT+T) you can write the command:

 touch filename.ext 

This will create an empty file called filename.ext - you can call it whatever you want, with whatever extension (or no extension) you feel like.

  • 2
    Thanks, I didn't know this command. But I still have to open a terminal at the desired location (ok nautilus-open-terminal can help me for that purpose). What I want to do is not to lose time to look for the folder I'm working in ! – remjg Oct 29 '12 at 17:38
  • Yes I agree that this is very tedious in comparison to the old way. Not sure why they removed it - probably not many that used it or something. – Gjermund Bjaanes Oct 29 '12 at 17:40
  • 2
    Normal users don't need this feature, they could even be mistaken ("Hey, I want to create a new .doc file, why not creating a blank new text file ?"). I can understand it, but I need it : it was a very convenient way to create a new source code file at the right project location. – remjg Oct 29 '12 at 17:47
  • I understand. I did not find any extension doing this sort of thing, but perhaps you could do the community a service and write one? ;) – Gjermund Bjaanes Oct 29 '12 at 17:51
  • I'm currently learning how to code, would be a lot of fun and an interesting task for me to contribute to a free software ! But I must say I'm overwhelmed for now. I studied math in the past, I teached for two years, and I'm going back to the university directly in the second year of a computer science master... Well, it's tough ! – remjg Oct 29 '12 at 17:59
  • A file that is zero bytes long is not always a valid file, so I'm not sure this is the correct approach for anything but plain text files. – Flimm Dec 15 '23 at 17:43
3

This guy saved me. Just put an empty file in ~/Templates/ and you'll see an ability to duplicate it into any folder when you right-click and do into "New Document".

Íhor Mé
  • 282
2

I guess you could write a nautilus script with touch "New files.txt" in it.

You could even keybind it using accels.

user55822
  • 3,125
  • 1
  • 17
  • 13
  • Even if I have found the answer, it sounds like an interesting idea for those who want a keyboard shortcut ! – remjg Oct 30 '12 at 15:44
  • If there still is the File->New Document->Empty Document entry, you can keybind it directly, no need for the script. – user55822 Oct 30 '12 at 17:31
  • How do you do it ? – remjg Oct 30 '12 at 20:48
  • 2
    Accels are shortcuts assigned to each entry inside menus. Read that question and answer http://askubuntu.com/questions/136062/permanent-custom-keyboard-shortcuts-for-evince-document-viewer/136112#136112. Applies to nautilus as well of course. – user55822 Oct 30 '12 at 21:57
2

I installed nautilus-terminal.

It gives you a small embedded terminal inside Nautilus.

The directory in the embedded terminal is identical to the directory you are watching in nautilus.

So you can use the touch command there without opening a separate terminal and changing directories manually.

kos
  • 35,891
hobgoblin
  • 21
  • 1
1

If you're on a localised Ubuntu version, you need to find the right translation for "Tempaltes". For example, on my French Ubuntu 20.04 version, "Templates" is called "Modèles"

1

To get back this functionality, I've written a simple guide http://bernaerts.dyndns.org/linux/344-nautilus-new-document-creation-menu to setup a customized right click contextual menu in Nautilus that allows you to create some empty documents fitted to your need.

For every document in the menu, you can set :

  • label and icon to use
  • the model to copy
  • the execute attribute (for shell script)

To allow this level of customisation, setup follows 3 steps :

  1. configuration of the list of document types in an INI file
  2. creation of document models for every document type
  3. generation of Nautilus action environment based on these types

This is supposed to provide a generic approach and to give some flexibility.

Hope it helps.

0

I use the create dopcument all the time in my www folder. unfortunately it seems to be broken when I upgraded to 14.04LTS. The Templates folder is missing in the root's home directory.

so this is how I fixed it. in my Templates folder in my home folder (you have to show hidden files btw) navigate there and for some reason it worked there. I right clicked and added the new document then I Right clicked and made a new document but I tittled the next one as newphp.php and another as newhtml.html

I edited both docs and included my default codes I used.

then I opened up a terminal and typed: gksu nautilus on the command line then navigated to the home directory that my computer boots into (default account), then copied the Templates folder (that I just made additional new files in ) then navigates to the root's home by clicking home in the nautilus menu that I launched as root, and paste the Templates folder in the root's home directory.