Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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)

share|improve this question

4 Answers 4

up vote 3 down vote accepted

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

share|improve this answer
    
Thanks DoR.. I've been busy myself and came back to the page to post my bash script :).. I'm very keen to see your python script.. but for now I'll just post mine..(need a break..It's been an all-nighter.) ... –  Peter.O Jan 22 '11 at 0:34
    
It's good...Thanks.... Python has a simplicity I like, but unfortunately it isn't simple to me (yet) :)... I'll stay focused on bash for a while longer, to try to get a decent intial understanding of it.. then I'll look further into python... (I've tried to give you a +1 but it says I marked you 2 hours ago.. I recall I did give you a +1, then I retracted it until I could have a good look at the answer...Now it says I can't change anything until the answer is modified/edited.. –  Peter.O Jan 22 '11 at 3:23
    
@fred.bear I made a tiny edit so you can vote now ;) –  Alvin Row Jan 22 '11 at 3:35

Its simple :)

Enabling

  1. Edit > Preferences

  2. Now look at the Plugins section.

  3. Select the check box next to the name of the plugin that you want to enable.

  4. You may now Click Close to close Gedit, Then start it again

Disabling

  1. Edit > Preferences

  2. Now look at the Plugins section.

  3. Deselect the check box next to the name of the plugin that you want to enable.

  4. You may now Click Close to close Gedit, Then start it again

share|improve this answer
    
Thanks Michael.. I seem to have not made it clear.. I assumed tht everyone sees the word "command" as I do... but they don't... I meant a command-line command (and you thought: menu command) .. I must ammende my question.. (+1.. you have presented a very clear answer) –  Peter.O Jan 21 '11 at 17:09

After finally finding a reference to gedit's plugins, I've put together a bash script...

Because this script is exclusive to gedit, adding it via gedit's External Tools localizes the scope of your choice of shortcut key to gedit only.. I'm using Ctrl+NumPad7 (because it is very close to PageUp and PageDown)...

#!/bin/bash
# Toggle gedit plugin ControlYourTabs  ON/OFF, with inverse switching for   
# Multi-Edit's "Columns Always Available" feature, which uses same shortcuts 
# ==========================================================================
cytab=controlyourtabs
plugins=$(gconftool-2 --get /apps/gedit-2/plugins/active-plugins)
#
if [[ "$plugins" =~ ^\[(.+,)*$cytab(,.+)*\]$ ]] ; then
    #
    # "Control Your Tabs" found in list... Disable it
    #  and enable "Multi Edit - Columns Always Available"  
    #
    if   [[ "$plugins" =~ ^.+\,$cytab(,.+)*\]$ ]] ; then plugins=${plugins/,${cytab}/}
    elif [[ "$plugins" =~   ^\[$cytab\,.+$     ]] ; then plugins=${plugins/${cytab},/}
    elif [[ "$plugins" =~   ^\[$cytab\]$       ]] ; then plugins=[]
    else echo "Logic Error in one of the regex patterns"; exit 1
    fi
    multi=true
else
    # "Control Your Tabs" NOT found in list... Enable it
    #  and disable "Multi Edit - Columns Always Available"  
    #
    plugins=${plugins%]},$cytab]
    multi=false
fi
#
gconftool-2 --set /apps/gedit-2/plugins/active-plugins --type=list --list-type=string "$plugins"
gconftool-2 --set /apps/gedit-2/plugins/multi_edit/columns_always_avail --type bool  $multi  

share|improve this answer

I was / am navigating this with regex and ipython plugins, that both want to run on ctrlr. I sniffed around in "regexsearchinstance.py" (in ~/.local/share/gedit/plugins/regex_replace) and found this:

def create_menu_item(self):
        """
        Create a menu item in the "Tools" menu.
        """
        action = gtk.Action("RegexSearch", 
                _("Regular expression..."), 
                _("Search using regular expressions"), None)
        action.connect("activate", self.on_open_regex_dialog)

        action_group = gtk.ActionGroup("RegexSearchActions")
        action_group.add_action_with_accel(action, "<control>r")

        manager = self._window.get_ui_manager()
        manager.insert_action_group(action_group, -1)
        manager.add_ui_from_string(ui_str)

I changed one line to:

action_group.add_action_with_accel(action, "<control><shift>f")

and quit gedit. Now regex searches load on ctrlshfitf. I see a comparable line in /usr/lib/gedit/plugins/ipython.py:

self._action_group.add_actions([('IPython', None,
        _('Run in IPython'), '<Control>r', _('Clear the document'),
        self.send_to_ipython)])

So if you want to actually edit the plugins so that they use different shortcuts by default, sniff around for <Control> or <control> or add_action in the plugin file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.