Ubuntu – Two gedit plugins clash. How to change shortcut keys, or enable/disable a plugin

command linegconfgeditpluginspython

Gedit has two plugins from Gnome's Gedit Plugins page which I both particularly want…

However they both vie for the same shortcut keys: Ctrl+PageUp and Ctrl+PageDown

I can see two possible solutions, and maybe there are more,,,(there usually is 🙂

The best solution may be to change the shorcut keys in Multi-edit to Shift+Ctrl+PageUp and Shift+Ctrl+PageDown… but I've very little python knowledge, and how to do it escapes me..

The simplest method (for me) is to just toggle them on/off via another shortcut-key. I know the command to toggle the Multi-edit feature on/off (but not the entire script)… Basically, for this option, I need a command to toggle a Gedit Plugin on/off..

Either, or both (,or other) solutions would be appreciated…

UPDATE: I'm looking for a command-line command (vs, a menu command),
and/or a 'fix' for Multi-edit's python script.

Note: The 'Edit Shortcuts' plugin does not show the Multi-edit plugin… (so I can't do it that way)

Best Answer

I wrote the following python script (download) that enables/disables the Multi-edit plugin:

#!/usr/env/python

import re
import commands

active_plugins = commands.getoutput("gconftool --get /apps/gedit-2/plugins/active-plugins")

r1 = re.compile(r'multi_edit')

if r1.search(active_plugins):
    # Disable multi-edit plugin
    active_plugins = re.sub("multi_edit,|,multi_edit","", active_plugins)

else:
    # Enable multi-edit plugin
    active_plugins = re.sub("]",",multi_edit]", active_plugins)
    
commands.getoutput("gconftool --set --type=list --list-type=string /apps/gedit-2/plugins/active-plugins "+active_plugins)

To toggle Multi-edit with a keyboard shortcut:

  1. Save the script as toggle-multi-edit.py in your home folder.

  2. Open up System → Preferences → Keyboard Shortcuts. Click Add and put python /home/<user>/toggle-multi-edit.py for the Command, replacing <user> with your actual username.

    alt text