Unbind/Rebind Ctrl+D in Gedit

After quite some googleing and experimenting I finally managed to change the behavior of Gedit and that annoying Ctrl+D shortcut. By default, pressing Ctrl+D deletes a line… very useful, I’m deleting lines all the time :roll-eyes:

To change this to something much more useful – like cutting the line and putting it into the clipboard – put the following into your ~/.gtkrc-2.0:

binding "override-ctrl-d" {
    bind "<ctrl>d" {
        "move-cursor" (display-line-ends, -1, 0)
        "move-cursor" (display-lines, 1, 1)
        "cut-clipboard" ()
class "GeditView" binding :highest "override-ctrl-d"

To completely disable Ctrl+D, use the following instead:

binding "override-ctrl-d" {
    unbind "<ctrl>d"
class "GeditView" binding :highest "override-ctrl-d"

The important bit about these snippets is really just “class "GeditView" .... Now I just need to figure out how to remove the next useless key binding Ctrl+Shift+U…


2 Responses to Unbind/Rebind Ctrl+D in Gedit

  1. alex pilon says:

    Right on man, now the Advance Editing CTRL + D (to duplicate line) works. Thanks!

  2. Nope says:

    Thanks for the tip. Ctrl+D is a really bad shortcut… it’s between Ctrl+S for saving the file, Ctrl+F to search it, and the clipboard shortcuts… it’s the worst placement possible for a line deletion shortcut :/ I regularly delete lines by mistake, and I’m quite certain I occasionally do not notice it and may have lost important stuffs because of it…

    I use FVWM as a window/panel manager, and another possibility is to use it to create a no-op shortcut valid only when Gedit window is focused to override Ctrl+D (the shortcut simply is not passed to Gedit):

    Key (gedit) D WTSF C Nop

    – WTSF = Window, Titlebar, Sides, Frame -the window corners-, so it applies wherever is the mouse… and if using ClickToFocus, ‘W’ makes it apply even if the mouse is outside the window, as long as Gedit is focused -of course if it isn’t, Ctrl+D isn’t a problem…

    – C = Ctrl.

    – Nop = no-op, i.e., do nothing.

    Other keyboard shortcut managers can of course do the same, if they support window-specific shortcuts, and do not pass the shortcut to the application if matched.

    Damn procrastination for waiting so long to search for a solution to this problem :/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: