89

I would like to to have a "create new document" option in the right-click menu.

Currently it looks like this :

enter image description here

I am using Ubuntu GNOME 16.04 LTS with GNOME 3.20.

muru
  • 193,181
  • 53
  • 473
  • 722
Severus Tux
  • 9,736
  • 9
  • 58
  • 97
  • 3
    Marked as a possible duplicate of [this answered question](http://askubuntu.com/questions/309834/missing-new-file-in-ubuntu-13-04) – gsxruk May 26 '16 at 09:42
  • Maybe Gnome is trying to be like Mac OS? Because Mac OS also just has "Create folder" and not "Create file/document". Here's Mac OS: https://imgur.com/a/Hc9aQbX – pavel_orekhov Jun 02 '19 at 20:54
  • 1
    The simplest solution is to use the single command: `$ touch ~/Templates/"New Document"` and this brings back the feature of add a _New Document_ named empty file to the directory. – Pe Dro Apr 06 '20 at 08:39
  • 4
    ubuntu 20.04 user here, any way to enable this option in desktop? the solutions here only work for file manager – Shihab Shahriar Khan Jun 19 '20 at 15:55

7 Answers7

131
  1. See if you have ~/Templates folder2. Create one if it is missing using command:

    mkdir ~/Templates
    
  2. Now create an empty file from command prompt:1

    touch ~/Templates/Text\ File.txt
    

The "Create Document" option is back again and you can create a new text file or a new document.

1 The backslash is used to tell the shell that the space following it is part of the filename. Since the shell recognizes spaces as delimiters between commands/options/arguments, unless you "quote it", 'quote it', or quote\ it, the shell will treat whatever comes after the space as a separate argument.

2 The ~/Templates folder is localized, change his name accordingly to your localization (ex: ~/Modèles for French localization).

HMagdy
  • 1,429
  • 2
  • 9
  • 8
  • 1
    what is the purpose of the \ after Text? – bobo Dec 18 '16 at 17:32
  • 4
    \ this is because of file name contains space you can use "" – HMagdy Dec 22 '16 at 09:25
  • 2
    I had no problems with 16.04, recently I upgraded to 17.04 and option is GONE. help. – Luka May 01 '17 at 19:01
  • 13
    This should be the correct answer – Matteo Jun 14 '17 at 12:57
  • 3
    Is there a way to edit the file's name upon creation ? currently it creates a text file with a default name "Text File.txt" – Roey Jan 08 '18 at 09:09
  • 1
    @Roey yes it's peace of cake. Just rename ~/Templates/whateveryouwant.txt or after creation, you can rename the created file. – HMagdy Jan 08 '18 at 10:13
  • 6
    @HassanMagdySaad **Upon creation** for every file without needing to manually rename it afterwards. This is how it works on MS Windows for any new file or folder with the right-click-menu. Thanks – Roey Jan 08 '18 at 10:43
  • 2
    @Roey you can press F2 immediately, but yeah, there must be some knob to turn to turn it into "rename mode after creation" by default. At least it works that way on CentOS 7, so it should be doable on ubuntu. – Dan M. Nov 15 '18 at 17:32
  • 1
    `touch ~/Templates/New\ File` if you do not want any extension. – arshovon Apr 30 '19 at 17:32
  • 3
    It is now 2020 and Ubuntu 18.04 still has this. This still works just cant believe they are not fixing this in the release. – Namphibian Feb 03 '20 at 04:47
  • does this work in desktop? ubuntu 20.04 – Shihab Shahriar Khan Jun 19 '20 at 15:53
  • @ShihabShahriarKhan It works, but not on the Desktop. See [this answer](https://askubuntu.com/a/1257289/249548) for more info. – Vadim Kotov Jul 08 '20 at 09:11
  • 1
    Wow! This is impressive. Could anyone provide a link to explain how this works? Does the OS look at the Templates folder and search for `File.txt` somewhere? – Nav May 07 '21 at 15:34
  • @Nav https://www.youtube.com/watch?v=967yhGf1JbQ and https://help.ubuntu.com/stable/ubuntu-help/files-templates.html.en give you good details about that – HMagdy May 08 '21 at 19:58
  • Still works great in Ubuntu 22.04. – KBurchfiel Apr 08 '23 at 18:39
20

You can go into your ~/Templates folder and create templates yourself, then they will appear in the right-click menu. For example:

cd Templates

touch Filename.txt
Naveen
  • 301
  • 1
  • 3
  • 6
  • I have the ~/Templates folder and created a newFile.txt there via CLI. still no new file entry in context menu. still does not work for me somehow on ubuntu 18.10 – Axel Werner Mar 24 '19 at 12:53
  • Please change the permission for this folder and file – Naveen Mar 25 '19 at 08:47
  • as suggested above, this is not the Templates folder per se, but the localised version. You can get your folder name by running : xdg-user-dir TEMPLATES, in Swedish this is Mallar for example so my output is /home/user/Mallar . – Vincent Gerris Oct 06 '22 at 13:33
12

This functionality has been removed from Nautilus 3.20 (either by error or on purpose). There is a bug report on it here. If it turns out to be a bug it will be fixed upstream and then will either be back in 3.22 or backported into 3.20, or if this has been done on purpose then as you can see from the LP bug report they are wanting to make it a distro specific patch.

  • 1
    The reported bug report above has been marked as duplicate of [Launchpad #1632027](https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1632027). Please vote on #1632027. – Hans Deragon Jan 06 '21 at 14:06
9

It seems like when the templates folder is empty this option is disabled. The simplest fix for this problem is to create a file in the templates folder:

touch `xdg-user-dir TEMPLATES`/Empty\ Text\ File.txt

It's definitely a bug as stated.

pr.nizar
  • 780
  • 2
  • 6
  • 17
  • 2
    nice hint about that "xdg-user-dir" tool. it showed me, that my TEMPLATE Variable/Folder/Setting was set to my $HOME only somehow. NOT to my Template folder. However even if i reset this setting to $HOME/Templates it didnt worked for me so far on Ubuntu 18.10 . – Axel Werner Mar 24 '19 at 12:56
  • Same for me. I wonder if GNOME needs to be informed of the update. – user643722 Aug 21 '21 at 10:08
  • this also translates the folder name to the proper language in my case, perfect. – Vincent Gerris Oct 06 '22 at 13:31
7

In the case you are using an ubuntu with a different language that english, first check where your Templates folder is.

vi ~/.config/user-dirs.dirs

And in this file, check for XDG_TEMPLATES_DIR=. In spanish for example you will have something like:

XDG_DESKTOP_DIR="$HOME/Escritorio"
XDG_DOWNLOAD_DIR="$HOME/Descargas"
XDG_TEMPLATES_DIR="$HOME/Plantillas"
XDG_PUBLICSHARE_DIR="$HOME/Público"
XDG_DOCUMENTS_DIR="$HOME/Documentos"
XDG_MUSIC_DIR="$HOME/Música"
XDG_PICTURES_DIR="$HOME/Imágenes"
XDG_VIDEOS_DIR="$HOME/Vídeos"

Then you can apply the solution listed in the other answers:

mkdir ~/Plantillas  (or the name listed before)
touch ~/Plantillas/Documento\ de\ Texto.txt

And that is all.

King Midas
  • 451
  • 5
  • 12
  • 3
    As the remarks in this configuration file states, these entries are set/updated by the ''xdg-user-dirs-update'' cli tool. So i did a ''xdg-user-dirs-update --set TEMPLATES ~/Templates'' to reset my Templates setting to the $HOME/Templates folder within my homedirectory. However... it still does not work for me somehow on ubuntu 18.10 . still no "new document" on my context menu. – Axel Werner Mar 24 '19 at 12:59
  • 1
    Thanks, this did actually work for my Ubuntu 20.04. I tried the other options of creating an empty document, but nothing. Then I find that the Templates variable is set to `$HOME`. Sigh... – John C Apr 28 '23 at 15:05
3

this method didn't quite work for me, items in the Templates folder weren't showing up in the context menu. something needed to be restored about how the system identifies and uses the Templates folder.

to fix this, i installed ubuntu tweak like so:

wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu xenial-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'
sudo apt-get update
sudo apt-get install ubuntu-tweak

and then used this method, namely, delete your Templates folder and then use this method to 'restore' the Templates folder, worked for me in 17.04 on a thinkpad t530:

How can I restore template functionality after having deleted the Templates folder in 12.10?

muru
  • 193,181
  • 53
  • 473
  • 722
  • It also wasn't working for me after deleting (and recreating) the `Templates` folder. A simpler solution than installing Ubuntu-Tweak that worked for me was [this one](https://askubuntu.com/a/94739/173693). – Garrett Jul 10 '19 at 09:16
1

You can also use the LibreOffice 'Save As' feature to save an empty Document, Spreadsheet, Presentation or Drawing in the same way. Using touch to create files won't work (didn't for me anyway) since ubuntu still recognises them as text files. So you can have any type of new file available if you set up the right template for it, not just text files.

mrchuck
  • 31
  • 6