Keyboard Shortcut to Rename File in GUI (Other Than F2)
I'm using Gnome instead of Unity, but they should be the same (more or less).
Nautilus (a.k.a. Files) keeps its keyboard shortcuts in ~/.config/nautilus/accels
File Rename is listed there as:
; (gtk_accel_path "<Actions>/DirViewActions/Rename" "F2")
The ;
means that it is commented out and Nautilus uses the system default.
If you remove the ;
and change the line to:
(gtk_accel_path "<Actions>/DirViewActions/Rename" "<Primary>Return")
Then File Rename will be changed to Control-Enter
.
It seems that there is only one shortcut possible for each operation. Nautilus uses the last one listed.
So you can't have F2
and Control-Enter
at the same time.
In order for the changes to take effect you have to stop nautilus. Run the following from the commandline (before you make the change):
nautilus -q
Detailed steps (on request):
-
open Files ('Nautilus')
-
browse to directory
.config/nautilus
in your home directory -
if you don't see directories starting with a dot, press
<Ctrl>H
or in the preferences for Files ('Nautilus'), tick the box for displaying hidden files. -
right-click or double-click file
accels
so that it opens in an editor (likelygedit
) -
Alternatively, hit
<Alt>F2
and give command:gedit ~/.config/nautilus/accels
Now we have the configuration file in an editor, we have to stop Files ('Nautilus') before we can make changes. Again, two ways of doing this:
- Option 1: open a terminal window (
Gnome Terminal
) and kill nautilus, by issuing command:nautilus -q
. Your Files window(s) should all disappear - Option 2: hit
<Alt>F2
and give commandnautilus -q
. Your Files window(s) should all disappear
Now Files ('Nautilus') has been stopped, we can make changes to its configuration files.
- In the editor, make the changes as listed above and save the file
- Exit the editor
If you now open Files ('Nautilus') again, your changes should take effect
Answers to foot notes:
- It is relevant to specify the application you're having a problem with. In this case, it was the configuration of the application as opposed to a system setting that had to be modified to resolve this issue.
- People will know what you mean by
GUI Environment
. It is however generally referred to asGUI
orDesktop
in this context.
ALT+Enter worked for me in the File Navigator, but then you have to use ESC to close.
Similar to Bring BackSpace back to nautilus (3.18+) once and for all!. We can use the same fix for Ubuntu 18.04+ (Nautilus 3.26+) to set the shortcut keys for rename.
1) Install Nautilus Python
apt-get install python-nautilus
2) Download Backspace-Back.py from Nautilus-backspace and put it in ~/.local/share/nautilus-python/extensions:
mkdir ~/.local/share/nautilus-python
mkdir ~/.local/share/nautilus-python/extensions
wget https://raw.githubusercontent.com/riclc/nautilus_backspace/master/BackspaceBack.py ~/.local/share/nautilus-python/extensions/BackspaceBack.py
3) Make a copy of the file (or rename) for the purposes of making a new shortcut (or put it all in that one file).
cp BackspaceBack.py Rename.py
4) Edit Rename.py and modify the line in the file that starts with app.set_accels_for_action to the following:
app.set_accels_for_action( "view.rename", ["<control>Return"] )
app.set_accels_for_action( "view.open-item-new-tab", [] )
5) Restart Nautilus (killall nautilus)
Note that "open-item-new-tab" also has to be modified to free up the Control+Return key combination and then reassign it to "rename".
You can use this to change any shortcut in Nautilus. The complete list of current shortcuts and their defaults can be pulled from the source code for Nautilus (search for nautilus_application_set_accelerator
).