Geany: Shortcut suggestions

Created on 23 Aug 2018  路  15Comments  路  Source: geany/geany

After trying for a while, geany is really easy to use.
But it could be great if it could support more shortcuts:

Suggested shortcuts:

  • To upper case
    e.g ctrl + u
  • To lower case
    e.g ctrl + l
  • To camel case (Only First Letter Of Each Word Is Upper Case)
    e.g ctrl + shift + u
  • Quick scroll down/up.
    e.g ctrl + scrolling mouse wheel (This is used as zoom in/out, but ctrl +/-/0 already did that)

All 15 comments

These are the sorts of things that a plugin could easily do, did you check that none of them already do?

Some of your suggested keybindings are already taken (eg ctrl+u is unindent) but you can change them to your hearts content except ctrl+scroll which is taken for zoom and can't be changed.

I didn't find a suitable plugin to add these shortcuts. Editor/IDE like Editplus or Eclipse have such shortcut by default.

What the actual default key is doesn't matter, as long as it's configurable.

About ctrl + scroll:
The ctrl + scroll is wasted when used on zoom, people rarely change the font size, when they need ctrl +/-/0 already did that.
But they do need to scroll quickly on a file that has many lines _(Both Editplus and Eclipse use it that way)_.

So, my suggestions are:

  • If you knew a plugin that can do this please suggest.
  • If there is no such plugin:

    • Provide the additional keys that don't exists yet.

    • Make those keys configurable, include ctrl + scroll.

Importance of such feature:
When using an editor/IDE, actually such small features make a huge difference, because that's the actions been used repeatedly & frequently, many times a day.
A simple feature, don't means it doesn't worth an implementation.
They are more important than a fashion feature from my view.
And, I also think basic features like this should be built-in, not via a plugin.

ctrl+scroll is set by the Scintilla widget, it would have to be changed there first I think.

Anybody can write a plugin, or if a suitable one exists the feature can be added, plugins are here.

Different people have different ideas on what makes a huge difference to their experience. Clearly nobody who currently uses Geany missed the feature enough to implement and contribute it, not even in a plugin.

@elextr So, when editing a large file, how do you scroll down/up quickly? I don't want to use the PgUp/PgDn ..., they waste time, and also on different keyboards they are located differently.

And the upper/lower keys are also very common I guess, otherwise they won't be implemented in most editors.

This is just suggestion for sure, what I propose is to make it available & configurable, so that people can change it to the way they like, but only when they want to of course.

when editing a large file, how do you scroll down/up quickly?

scrollbar?

As I said, scrolling is a function of the editing widget Geany uses, any extra features need to be implemented there first.

And the upper/lower keys are also very common I guess, otherwise they won't be implemented in most editors.

Mixed case is very common in particular programming languages and not in others, maybe most Geany users don't use mixed case so much. I'm just pointing out that the lack hasn't annoyed anyone enough so far for them to contribute anything more than Toggle case of selection. To be clear Geany is a totally volunteer project, things happen only because somebody contributes it, so if it doesn't exist then either its not wanted enough to make the effort or far too hard (and it really isn't far too hard).

@kuchaguangjie if case fiddling is so important to your workflow then maybe you could contribute a pull request?

@elextr I want to, but I am not a professional C programmer.
But I always like C programming, so I might have a try.

You probably know, toggling case (lower vs. upper case) can already be done with Ctrl-Alt-u and this shortcut can also be configured.

For CamelCase conversion, ages ago I wrote a simple little Python script to just do that:
https://gist.github.com/eht16/52067a31f2d8cfc3c0fac87d2ab70e28

Configure this script in Geany as command in the "Send selection to" settings, like in the screenshot.
Then select some text and use Edit->Send Selection to->CamelCase. The script also tries to detect if it is CamelCase to convert to lower_case and vice versa.
For me this works fine since a couple of years.

If I find time, I'll put it in the wiki.
HTH.
geany_camel_case

@eht16 I think toggle case is still different from to lower/upper, because if you want to change Hi to HI, with ctrl + alt + u, you need to press the shortcut twice to perform the transformation, which is unnecessarily complex.
So, I think it's better to have 2 separated shortcuts for to upper and to lower.
And, in addition, a camel case shortcut.
The toggle shortcut is not that useful in my experience.

@kuchaguangjie you can use the custom command feature @eht16 referred to for any kind of transformation like this, using any programming language you want. For example in Python you could make the up/down commands something like this (untested):

# up
python -c 'import sys; sys.stdout.write(sys.stdin.read().upper())'
# down
python -c 'import sys; sys.stdout.write(sys.stdin.read().lower())'

As for fast scrolling, a couple alternatives are to use the Page Up and Page Down keys (available on full US keyboards at least), and/or you could use the Overview Plugin to quickly jump over large ranges in the file.

If those aren't suitable and you know more Python than C, C++, or Vala, you could use GeanyPy to implement such a feature in your own plugin.

@codebrainz I will give a try thanks.

@eht16 @codebrainz
I have defined several very simple python scripts for to lower / upper / capital command separately, based on @eht16 's script, and assigned shortcut CTRL + L , CTRL + U , CTRL + SHIFT + U to them respectively, it works on my Linux machine now.

The scripts

geanyLowerCase.py:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# geany - customized formatting - to lower case,
import sys

def lower_case(string):
    return string.lower()

def main():
    data = sys.stdin.read()
    sys.stdout.write(lower_case(data))

if __name__ == '__main__':
    main()

geanyUpperCase.py:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# geany - customized formatting - to upper case,
import sys

def upper_case(string):
    return string.upper()

def main():
    data = sys.stdin.read()
    sys.stdout.write(upper_case(data))

if __name__ == '__main__':
    main()

geanyCapitalCase.py:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# geany - customized formatting - to capital case,
import sys

def capital_case(string):
    return string.title()

def main():
    data = sys.stdin.read()
    sys.stdout.write(capital_case(data))

if __name__ == '__main__':
    main()

Additional steps to make it work

  • Link these scripts under $PATH.
  • Add script as command in geany.

    • in geany,

    • edit -> format -> send selection to -> set custom commands,

    • add the script, and label it,

    • remember its order in the commands,

  • Define shortcut for new commands.

    • edit -> preference -> keybindings -> format,

    • change key for "send to custom command x",

      where x is the order of you new command when define it,

  • Test it.
  • Done.

Possible improvements needed

  • After format via shortcut, the select text are not selected any more.
    Maybe it's better to still select those text after the action.
  • This is tested on Linux, not on windows yet.
    Might need to modify the script a bit to make it work, e.g the shebang part.

Tips

  • The capital case applies to all selected words.
    e.g hi, how are you? -> Hi, How Are You?

Update - simpler solution without additional script file

As @codebrainz said in comment below:
For windows or solution without script file, check: https://github.com/geany/geany/issues/1929#issuecomment-416446747

@kuchaguangjie neat, nice info. You can get the same result without writing separate files or adjusting $PATH using the one-liners I posted above, can just plug them right in as "custom commands".

@codebrainz Ok, got it, and I just update the comment with a capital case script.

@codebrainz Just make it work on windows with command only without script file as suggested.

This simpler solution works for both linux and windows, and probably mac too.

Commands:

  • lower
    python -c "import sys; sys.stdout.write(sys.stdin.read().lower())"
  • upper
    python -c "import sys; sys.stdout.write(sys.stdin.read().upper())"
  • capital
    python -c "import sys; sys.stdout.write(sys.stdin.read().title())"

But it's a bit different from linux, to make it work need to make sure following tips are applied.

Tips:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

webdev23 picture webdev23  路  8Comments

arigit picture arigit  路  6Comments

AdamDanischewski picture AdamDanischewski  路  13Comments

Aran-Fey picture Aran-Fey  路  5Comments

fyah picture fyah  路  4Comments