Author Topic: Macros for cursor movement/ selection / deletion  (Read 3922 times)

Graeme

  • Senior Community Member
  • Posts: 2208
  • Hero Points: 272
Macros for cursor movement/ selection / deletion
« on: January 20, 2007, 12:44:03 pm »
In response to this request http://community.slickedit.com/index.php?topic=919.msg3941#msg3941
I've added a little bit of code to my delete_next_token macro to achieve what was asked for.  If you prefer not to leave a whitespace char, change the default parameter to false.

This code has been tested in Slick V12 but the basic code worked ok in V11.  It doesn't necessarily work with hard tabs - I don't use them so I haven't attempted to test with them.  Also I've ignored anything to do with macro recording i.e. name attributes and calls to _macro functions so I don't know what will happen if you record a macro that calls one of these functions. 

I'm not 100% sure I know what I'm doing with regard to how selections are handled, so this code may behave differently for you, depending on what options you have set in tools -> options -> general -> selections.

A curious thing is that if I add name_info attributes to select_next_token, select_prev_token, repeated selection fails  - I'm too lazy to try and solve this by e.g. experimenting with parameters to _select_char !

If you fix or add anything to this code, please post it back to the forum.
In case you're interested, I use the following key bindings with these macros (C == Ctrl, S == shift)

cursor_to_next_token                    ALT + right-arrow
cursor_to_prev_token                    ALT + left-arrow
find_next_word_at_cursor                C+F3
find_prev_word_at_cursor                C+S+F3
repeat_find_word_at_cursor              F3
repeat_find_word_at_cursor_reverse      S+F3
select_to_next_token                    C+S+right-arrow
select_to_prev_token                    C+S+left-arrow
delete_next_token                       C+Del
delete_prev_token                       C+Backspace

For Ctrl+right arrow I still use Slick's next-word, prev-word.

If you're not familiar with loading macros, copy the attached code to vusrmacs.e (minus the #includes etc at the start if they're already there), delete anything you don't want and load it with "load module" on the macro menu.  If it causes a problem, you can unload with "unload module" and you can use Ctrl-Alt-Shift-F2 (see keyboard emulations) to break a locked up macro.

There's a few extra functions in the code besides the ones mentioned so please review all of it before loading, to see what commands are being added to your system.  The "fast_move" ones are commented out.

Graeme