Hi all,
I am a first time geany user after searching for a replacement for my old die-hard Nedit 'tendencies". FWIW the column editing mode is invaluable to me and already a reason to not go back to Nedit. Makes me want to make a geany zenburn color scheme..
Anyhow, is there an equivalent of Nedit's "Shift right" <Ctrl>0 and "shift left" <Ctrl>9 in geany? I dug through the FAQ, mailing list and manual but found nothing.
Thanks
-- Andrew Janke (a.janke@gmail.com || http://a.janke.googlepages.com/) Canberra->Australia +61 (402) 700 883
On Wed, 4 Mar 2009 21:49:40 +1100 Andrew Janke a.janke@gmail.com wrote:
Anyhow, is there an equivalent of Nedit's "Shift right" <Ctrl>0 and "shift left" <Ctrl>9 in geany? I dug through the FAQ, mailing list and manual but found nothing.
Waht do you undertand under shift right/shift left? I'm to lazy to consult the manual of Nedit ;)
cheers, Frank
Hi Frank,
Thanks for the reply.
Anyhow, is there an equivalent of Nedit's "Shift right" <Ctrl>0 and "shift left" <Ctrl>9 in geany? I dug through the FAQ, mailing list and manual but found nothing.
Waht do you undertand under shift right/shift left? I'm to lazy to consult the manual of Nedit ;)
If you for example rectangular select the middle 'column' in the following in Nedit: (eg: in the first line it would be 'blah.')
fred.blah.pl mary.john.pl fred.blah.pl mary.john.pl fred.blah.pl mary.john.pl fred.blah.pl
You can then press <Ctrl>9 a few times and quickly get this:
blah.fred.pl john.mary.pl blah.fred.pl john.mary.pl blah.fred.pl john.mary.pl blah.fred.pl
In what I do I am often fiddling about with such blocks of filenames and code.
Thanks
-- Andrew Janke (a.janke@gmail.com || http://a.janke.googlepages.com/) Canberra->Australia +61 (402) 700 883
Hi Andrew, hi list
On Wed, 4 Mar 2009 22:17:28 +1100 Andrew Janke a.janke@gmail.com wrote:
If you for example rectangular select the middle 'column' in the following in Nedit: (eg: in the first line it would be 'blah.')
fred.blah.pl mary.john.pl fred.blah.pl mary.john.pl fred.blah.pl mary.john.pl fred.blah.pl
You can then press <Ctrl>9 a few times and quickly get this:
blah.fred.pl john.mary.pl blah.fred.pl john.mary.pl blah.fred.pl john.mary.pl blah.fred.pl
In what I do I am often fiddling about with such blocks of filenames and code.
I'm afraid I don't know of any way how to do it right now (please correct me when I'm wrong) and I'm not sure whether this feature is useful to be part of Geany's main distribution. But I can imagine of two ways how to implement this: 1.) Creating a small [shell|python|perl|ruby|awk|sed|...]script and use it with custom command feature http://www.geany.org/manual/current/index.html#send-text-through-definable-c... 2.) Building a plugin for doing this which would cause a lot of overhead but makes it maybe more comfortable for other users.
Thanks, Frank
On Wed, 4 Mar 2009 23:42:10 +0100, Frank wrote:
Hi Andrew, hi list
On Wed, 4 Mar 2009 22:17:28 +1100 Andrew Janke a.janke@gmail.com wrote:
If you for example rectangular select the middle 'column' in the following in Nedit: (eg: in the first line it would be 'blah.')
fred.blah.pl mary.john.pl fred.blah.pl mary.john.pl fred.blah.pl mary.john.pl fred.blah.pl
You can then press <Ctrl>9 a few times and quickly get this:
blah.fred.pl john.mary.pl blah.fred.pl john.mary.pl blah.fred.pl john.mary.pl blah.fred.pl
In what I do I am often fiddling about with such blocks of filenames and code.
I'm afraid I don't know of any way how to do it right now (please correct me when I'm wrong) and I'm not sure whether this feature is useful to be part of Geany's main distribution.
I actually think this would be an awesome improvement and could go into Geany but it still needs someone to write it. So, patches are welcome.
In the meantime, Frank's alternative suggestions still apply.
Regards, Enrico
On Thu, 5 Mar 2009 00:21:56 +0100 Enrico Tröger enrico.troeger@uvena.de wrote:
I actually think this would be an awesome improvement and could go into Geany but it still needs someone to write it. So, patches are welcome.
Hmm...ok. Since I'd like to learn something, can somebody of you give me a near life case study for this feature? Even I guess I understood what it should do, I'm ot sure, why and when to use it.
Cheers, Frank
On Thu, 5 Mar 2009 10:23:16 +0100 Frank Lanitz frank@frank.uvena.de wrote:
Hmm...ok. Since I'd like to learn something, can somebody of you give me a near life case study for this feature? Even I guess I understood what it should do, I'm ot sure, why and when to use it.
It's simple a shortcut for the move of an column block. For now, you have to mark the column block from (bottom to top), cut it out, move to the left (right) and insert it again. Using the mentioned shortcut, you would the the block moving without the need to cut it out and moving the cursor to the new position.
I actually think this would be an awesome improvement and could go into Geany but it still needs someone to write it. So, patches are welcome.
Hmm...ok. Since I'd like to learn something, can somebody of you give me a near life case study for this feature? Even I guess I understood what it should do, I'm ot sure, why and when to use it.
Sure. I use this all the time for renaming bunches of tiles for example...
gordon:goo$ ls -1 20056311.21-10-2008-135441.3D_T1.mnc 20056385.21-10-2008-131827.2D_T2.mnc 20056385.21-10-2008-131827.3D_T1.mnc 20056436.22-10-2008-132614.2D_T2.mnc 20056436.22-10-2008-132614.3D_T1.mnc 20056543.24-10-2008-144859.2D_T2.mnc 20056543.24-10-2008-144859.3D_T1.mnc ...
These are a bunch of MRI images that I want to rename so that the date (second "field") is in yyyymmdd format as per the first column. Yes I could do this via some awful perl/shell/awk/sed script and if it was something that I was to do all the time I would. The point is I deal with 1000's of these files every week and each case is always slightly different. So I find myself doing this:
gordon:goo$ EDITOR=nedit vidir . (I have an alias for this as opposed to normally using vi)
Which gives me this.. (in nedit)
1 ./20056311.21-10-2008-135441.3D_T1.mnc 2 ./20056385.21-10-2008-131827.2D_T2.mnc 3 ./20056385.21-10-2008-131827.3D_T1.mnc 4 ./20056436.22-10-2008-132614.2D_T2.mnc 5 ./20056436.22-10-2008-132614.3D_T1.mnc 6 ./20056543.24-10-2008-144859.2D_T2.mnc 7 ./20056543.24-10-2008-144859.3D_T1.mnc ...
First, a quick vertical select and delete or two gives me this.
1 ./20056311.21102008-135441.3D_T1.mnc 2 ./20056385.21102008-131827.2D_T2.mnc 3 ./20056385.21102008-131827.3D_T1.mnc 4 ./20056436.22102008-132614.2D_T2.mnc 5 ./20056436.22102008-132614.3D_T1.mnc 6 ./20056543.24102008-144859.2D_T2.mnc 7 ./20056543.24102008-144859.3D_T1.mnc ...
Then select the "day" part and press <Ctrl>0 (6 times)
1 ./20056311.10200821-135441.3D_T1.mnc 2 ./20056385.10200821-131827.2D_T2.mnc 3 ./20056385.10200821-131827.3D_T1.mnc 4 ./20056436.10200822-132614.2D_T2.mnc 5 ./20056436.10200822-132614.3D_T1.mnc 6 ./20056543.10200824-144859.2D_T2.mnc 7 ./20056543.10200824-144859.3D_T1.mnc
And the same for the "year" and press <Ctrl>9 (2 times).
Now Save, quit and grin. I also use this sort of feature a lot for reorganising chunks of code in "columns". Here for example is a bunch of code that I am currently writing to export some DICOM images..
$d->{'0008'}{'0005'} = &create_element('0008', '0005', 'ISO_IR 100'); $d->{'0008'}{'0008'} = &create_element('0008', '0008', 'DERIVED\PRIMARY\RECON TOMO\EMISSION'); $d->{'0008'}{'0012'} = &create_element('0008', '0012', '20090303'); $d->{'0008'}{'0013'} = &create_element('0008', '0013', '224555'); $d->{'0008'}{'0014'} = &create_element('0008', '0014', '777.777.0.0.0'); $d->{'0008'}{'0016'} = &create_element('0008', '0016', '1.2.840.10008.5.1.4.1.1.20'); $d->{'0008'}{'0018'} = &create_element('0008', '0018', '777.777.0.0.0.1236080755.2932837459.1440010230.3400850238'); $d->{'0008'}{'0020'} = &create_element('0008', '0020', ''); $d->{'0008'}{'0021'} = &create_element('0008', '0021', '');
And say that I wanted to quickly swap the Element and Group fields about (the hash references).
I should also note that in Nedit's case the Shift (column) Right and Left functions are simply "overloaded" versions of the normal case. ie:
Select text normally and shift right == indent Vertical Select text and shift right == column shifting as per above.
a
Andrew Janke wrote:
Sure. I use this all the time for renaming bunches of tiles for example... [...] gordon:goo$ EDITOR=nedit vidir . (I have an alias for this as opposed to normally using vi) [...] First, a quick vertical select and delete or two gives me this. [...] Then select the "day" part and press <Ctrl>0 (6 times) [...] And the same for the "year" and press <Ctrl>9 (2 times).
Now Save, quit and grin. [...]
Um, that sounds like something more suited to a simple sed or awk script; something like this:
ls | sed -r -n 's/^([0-9]+.)([0-9]{2})-([0-9]{2})-([0-9]{4})(-.*.mnc)$/mv \1\2-\3-\4\5 \1\4\3\2\5/p' | sh
or something (probably cleaner if you use the hold buffer). If you do this a lot, it might be better to script it than to rely on editing it the same way each time.
Um, that sounds like something more suited to a simple sed or awk script; something like this:
ls | sed -r -n [line noise]
Or mmv.
In any case I have decided to have a bit of fun with geany and managed to bash this together in the last hour or two.
http://mavis.anu.edu.au/geany/shiftcolumn-0.1.tar.gz
There seems to be a change in the API between 0.15 and 0.16 with p_document and document.h. For now the plugin doesn't do much except put the current selected text when you press <Ctrl>9 I spent time trying to figure out the plugin API for keybindings and the likes instead.
Can one of the Geany Devs please let me know if I am on the right track? From here I think it is just a bit more scintilla fiddling (get position, rotate text) and it should all work. (plus a bit of bounds checking).
thanks
-- Andrew Janke (a.janke@gmail.com || http://a.janke.googlepages.com/) Canberra->Australia +61 (402) 700 883
In any case I have decided to have a bit of fun with geany and managed to bash this together in the last hour or two.
Scratch that, the version there now will work (in a fashion...) if you just select a bit of text in a single line. Perhaps someone more familiar scintilla might be able to point out a better way of doing things than I currently am..
ie: for things like this do you just suck in the entire lot with sci_get_text and sci_set_text? for now the way I am modifying the text seems a little kludgy. Anyhow with a bit of luck and a bit more fiddling I should have it working soon.
-- Andrew Janke (a.janke@gmail.com || http://a.janke.googlepages.com/) Canberra->Australia +61 (402) 700 883
Well in order to continue my habit of replying to myself... :) Here is a "finished" version where all the functionality seems to work. Note that when you shift in "normal" mode, the selected text is quite happy to head up to the line above. I originally thought this was a bug but now I am starting to use this 'feature". ;)
The keys are initially mapped to <Ctrl>9 and <Ctrl>0. Get it here:
http://mavis.anu.edu.au/geany/shiftcolumn-0.2.tar.gz
It does need testing, so please let me know if it breaks anything for you.
Thanks
-- Andrew Janke (a.janke@gmail.com || http://a.janke.googlepages.com/) Canberra->Australia +61 (402) 700 883
On Mon, 9 Mar 2009 01:40:15 +1100 Andrew Janke a.janke@gmail.com wrote:
Well in order to continue my habit of replying to myself... :) Here is a "finished" version where all the functionality seems to work. Note that when you shift in "normal" mode, the selected text is quite happy to head up to the line above. I originally thought this was a bug but now I am starting to use this 'feature". ;)
The keys are initially mapped to <Ctrl>9 and <Ctrl>0. Get it here:
http://mavis.anu.edu.au/geany/shiftcolumn-0.2.tar.gz
It does need testing, so please let me know if it breaks anything for you.
Can you please check your build system again? It's trying to compile content of po/ which isn't there inside your tarball.
Cheers, Frank
On Mon, 9 Mar 2009 02:08:39 +1100 Andrew Janke a.janke@gmail.com wrote:
Can you please check your build system again? It's trying to compile content of po/ which isn't there inside your tarball.
oops, Try again now.
Now it compils but gives a lot of compiler warnings here on AMD64. I will check later and maybe send a patch. But nevertheless it seems to work and I'm starting to like it. ;)
Cheers, Frank
On Mon, Mar 9, 2009 at 02:36, Frank Lanitz frank@frank.uvena.de wrote:
Now it compils but gives a lot of compiler warnings here on AMD64. I will check later and maybe send a patch. But nevertheless it seems to work and I'm starting to like it. ;)
Good good. I am not surprised re the 64 bit squealing, my home machine is 32 bit (T42 Thinkpad + Ubuntu Intrepid) but work is 64 bit so I had planned to try it there later this week. As for the code itself I am sure there are bugs in there and I am also sure it could be done more efficiently. But as you say, it seems to work so I am a happy camper and can now dump nedit.
The one thing I don't understand though is how to get scintilla to put the select box back to where it was after an undo operation. Perhaps one of the geany devs with more experience can comment. ie: Select rectangular chunk, <Ctrl>9 and then <Ctrl>z removes the selection. :(
I'll add the po stuff back in for 0.3
a
Hi,
On Sun, 8 Mar 2009 16:36:49 +0100 Frank Lanitz frank@frank.uvena.de wrote:
On Mon, 9 Mar 2009 02:08:39 +1100 Andrew Janke a.janke@gmail.com wrote:
Can you please check your build system again? It's trying to compile content of po/ which isn't there inside your tarball.
oops, Try again now.
Now it compils but gives a lot of compiler warnings here on AMD64. I will check later and maybe send a patch.
Please find a patch attached.
Cheers, Frank
On Thu, Mar 5, 2009 at 4:23 AM, Frank Lanitz frank@frank.uvena.de wrote:
On Thu, 5 Mar 2009 00:21:56 +0100 Enrico Tröger enrico.troeger@uvena.de wrote:
I actually think this would be an awesome improvement and could go into Geany but it still needs someone to write it. So, patches are welcome.
Hmm...ok. Since I'd like to learn something, can somebody of you give me a near life case study for this feature? Even I guess I understood what it should do, I'm ot sure, why and when to use it.
It sounds like rectangle-mode in Emacs, or column-editing mode in TextMate.
One common use case is formatting data or code.
For instance, say I wanted to work with the whitespace between the first and second tuple elements in each row of the follow code:
call_foo([ (a, 1, 1), (b, 2, 2), (c, 3, 3), (d, 4, 4), (e, 5, 5) ])
I would select a rectangular region of text between the comma in the first row, and the second tuple element in the fifth row (covering the whitespace right down the middle). Then I can use "shift-left" and "shift-right" commands to move the entire rectangle around, "grow" or "shrink" commands to change the whitespace, or "kill" to clear the space and close it up.
In Emacs, you select the rectangle by dropping a mark in one corner, and placing the cursor in the other. In TextMate, you can hold down a key and drag the mouse to select a rectangle of text on the screen.
Maris