33

Since I spend a lot of time on my laptop, I've gotten used to using keyboard shortcuts for everything. I want to be able to switch from tab to tab of opened documents in gedit by pressing Ctrl+Tab and Ctrl+Shift+Tab. Are there config files I can edit, or is there something else I can do to enable this functionality?

Alternatively, can anyone post a list of keyboard shortcuts in gedit?

7
  • 11
    I don't know why the hell anyone would think ctrl+alt+pageup/down was a sane shortcut for anything, especially tab switching.
    – weberc2
    Feb 28, 2013 at 23:35
  • Yeah, I prefer my shortcuts to be mostly one-handed affairs. Control-Alt things I usually reserve for user- and system- related big tasks. Mar 1, 2013 at 14:11
  • @weberc2 I use two-handed shortcuts for typing related tasks. That's where I use both hand while typing anyway. Only stuff where I will switch mouse and keyboard often need a single hand shortcut (like Copy-Paste).
    – MadMike
    Nov 14, 2013 at 9:27
  • @MadMike Unfortunately, I use gedit for reading more than writing. Usually I have some word file open in it. Regardless, page up/down keys aren't even in standard locations, and they're almost never on the same keyblock as your hands. If you have to move your hand to hit the page up/down keys, you may as well just move it a little further to the mouse.
    – weberc2
    Nov 14, 2013 at 18:10

6 Answers 6

11

There used to be an option to enable editable menu accelerators for GNOME apps. The GNOME team removed the GUI for this, but at least under GNOME 2 it was still available via gconf. Recent Ubuntu versions use GNOME 3; I'm not sure of whether that still works (since GNOME 3 has migrated to dconf). I tried it in the old gconf-editor, and setting the option /org/gnome/desktop/interface/can-change-accels using dconf-editor, but it doesn't seem to work in Gedit (v3.4 on Precise).

According to Where to configure shortcut keys of Nautilus?, it doesn't work with Unity's global menu. You could load a different desktop environment and make the change there (if it works).

It may still be possible to edit the keyboard shortcuts by editing configuration files. According to a commenter on the (very outdated) Gedit shortcuts documentation page:

You don't really need a plugin to change keyboard shortcuts. This (also) works:

~/.config/gedit/accels:

; gedit GtkAccelMap rc-file         -*- scheme -*-
(gtk_accel_path "<Actions>/GeditWindowActions/DocumentsPreviousDocument" "<Control>Page_Up")
(gtk_accel_path "<Actions>/GeditWindowActions/DocumentsNextDocument" "<Control>Page_Down")
(gtk_accel_path "<Actions>/GeditWindowActions/SearchFindPrevious" "<Shift>F3")
(gtk_accel_path "<Actions>/GeditWindowActions/SearchFindNext" "F3")

~/.config/gtk-3.0/gtk.css:

 @binding-set unbind-ctrl-d {
         unbind "<ctrl>d";
         unbind "<shift>F10";
         unbind "<ctrl>Page_Up";
         unbind "<ctrl>Page_Down";
 }
 GtkTreeView { gtk-key-bindings: unbind-ctrl-d; }
 GtkTextView { gtk-key-bindings: unbind-ctrl-d; }

According to one commenter, Ctrl-Tab is hardcoded and cannot be rebound easily, but there is a plugin that purports to do this. To install the plugin, see How do I install a plugin for gEdit v3?.

For gedit2, the plugin files go in ~/.gnome2/gedit/plugins.


If you're unable to get it to work, you could use a different editor that lets you edit shortcuts, such as KDE's Kate.

The list of default keyboard shortcuts in Gedit is available in the manual. Click "Help" > "Contents" > "Shortcut keys" in Gedit to access it.

5
  • The plugin is what I want; where do I put the decompressed tar? Nov 30, 2012 at 21:41
  • 1
    Never mind, found here Nov 30, 2012 at 21:53
  • 4
    None of this works in 14.04.Trusty. can-change-accels has no effect when set with either gconf-editor or dconf-editor. When manually editing accels file, changes have no effect and they are overwritten when gedit exits.
    – haelix
    Nov 18, 2014 at 8:21
  • @haelix and others - don;t use gedit to edit the file. The css solution works with Gnome 3.14
    – Wilf
    Jul 3, 2015 at 13:42
  • @haelix Try to use your brain a bit, I get quite a good results by doing so. Applications usually read their configuration files while starting, so you need to start the application in order to apply your changes. If the application overwrites its configuration file while exiting, then you need to edit that configuration file while the application is not running, obviously. This is just a general advice, I'm not saying it will solve your issue with gedit. Oct 29, 2023 at 17:47
8

I have written a plugin for Gedit 3.30 and later (included in Ubuntu 18 and later) which adds some common keyboard shortcuts.

Ctrl+Tab / Ctrl+Shift+Tab for navigating between documents
Ctrl+Y for Redo
Ctrl+G for Go to line
Ctrl+E for Delete line(s)

(And it is fairly straightforward to modify the plugin to change the key combinations for these operations.)

https://github.com/foolo/gedit_custom_keys/

Just copy the files to the gedit plugin directory.

4
  • how to undefine existing shortcut? i.r. ctrl+d
    – jangorecki
    Sep 7, 2020 at 16:26
  • 2
    @jangorecki, unfortunately Ctrl+D for delete line is hard-coded in gedit's source code (in function gedit_view_class_init in gedit-view.c), so it's not possible without patching that code and re-compiling gedit. There are some notes about things that don't work, on github.com/foolo/gedit_custom_keys
    – foolo
    Sep 8, 2020 at 17:18
  • 1
    thanks, ctrl+d is just next to ctrl+s, and when you have a new keyboard with different layout it is very easy to hit it... it is so annoying it cannot be disabled
    – jangorecki
    Sep 8, 2020 at 17:34
  • thank you kindly sir!
    – Karl Pokus
    Mar 14, 2021 at 20:28
3

At least for Lubuntu 13.10, you can edit .config/gtk-3.0/gtk.css, here's mine:

@binding-set unbind-ctrl-d {
        unbind "<ctrl>d";
        unbind "<shift>F10";
        unbind "<ctrl>Page_Up";
        unbind "<ctrl>Page_Down";
}
GtkTreeView { gtk-key-bindings: unbind-ctrl-d; }
GtkTextView { gtk-key-bindings: unbind-ctrl-d; }
4
  • 1
    I don't understand your answer. Maybe you could include a little explanation with your pasted config file? Without any further explanation, it looks like that all this does is remove some keyboard bindings. Nov 16, 2013 at 22:33
  • @WindowsEscapist It's exactly what it looks like, simply remove some gtk keyboard bindings, including <ctrl>d, which interferes with gedit's ones.
    – RubenCaro
    Nov 23, 2013 at 8:03
  • So you remove these bindings to allow a binding of Ctrl+Tab, etc? I'm not very familiar with editing bindings as a whole, so it would be nice if you could add a bit of explanation - why does this work? Maybe not an ELI5, but an ELI7. Sorry. (Upvoted anyway, thanks for the answer!) Nov 26, 2013 at 23:40
  • @WindowsEscapist It's just removing these four bindings that bother for some apps. The one you are interested is <ctrl>d. If you do not want to unbind <shift>F10 simply remove its unbind line. And so on...
    – RubenCaro
    Dec 27, 2013 at 19:54
2

For Ubuntu 12.04 and up:

Use dconf-editor instead of gconf-editor

sudo apt-get install dconf-tools

Then set dconf>org>gnome>desktop>interface>can-change-accels to true

Setting shortcuts when using global menu (which is the case in Unity):

  1. Open evince (or any app) with UBUNTU_MENUPROXY=0 evince
  2. Browse menus, hover an entry, type your shortcut
4
  • Can you explain the Unity option more? gedit doesn't have a hover-able menu option so that one can set a custom shortcut with the unity method though. Nov 30, 2012 at 21:50
  • In Unity, menus are in the top panel (previously named global menu) and you can't set your shortcuts with it. If it's the hover part you don't understand, 1. open gedit in terminal using UBUNTU_MENUPROXY=0 gedit, then go to the regular menu, place your mouse cursor on an entry, type your shortcut (eg Ctrl+x), then close gedit, done.
    – user55822
    Nov 30, 2012 at 22:18
  • But in gedit, there is no entry to switch documents, only to go to a specific document. Dec 1, 2012 at 0:48
  • Well nevermind .. there are Documents->Previous document and Documents -> Next entries, but ctrl+tab doesnt work, sorry. Ctrl+[twosuperior] does ...
    – user55822
    Dec 1, 2012 at 9:22
1

I have a 64-bit Ubuntu 14.04 LTS and the folder with the plugins is /usr/lib/x86_64-linux-gnu/gedit/plugins/

Copying inside it the *.plugin and *.py files from https://github.com/baxterross/GEdit3TabSwitch, and then activating the plugin in gedit > Edit > Preferences > plugins made the trick for me.

For the shortcuts, here are a few: http://www.shortcutworld.com/en/linux/gedit_2.3.html

1

There is a plugin which restores the expected Ctrl+Tab, Ctrl+Shift+Tab tab switching. It was originally created for Gedit 3, but I updated the plugin for Gedit 3.8 and above.

You can download it from GitHub, installation instructions are in the Readme. https://github.com/baxterross/GEdit3TabSwitch

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .