Custom keyboard shortcuts in gedit

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?

Asked By: WindowsEscapist

||

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, CtrlTab 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.

Answered By: Mechanical snail

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
Answered By: user55822

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; }
Answered By: RubenCaro

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

Answered By: Baxter Ross

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

Answered By: Fernando Mlró Mlró

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.

Answered By: foolo
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.