for any programmer, these hotkeys are essential.
luckily for me, my text editor (Vim) lets me do this with a simple plugin:
https://github.com/tpope/vim-surround
vimscript code is pretty rough to understand. but you might look there for some inspiration. it has other features that you may want to implement, such as delete wrapping and change/swap:
Code: Select all
Details follow on the exact semantics, but first, consider the following
examples. An asterisk (*) is used to denote the cursor position.
Old text Command New text ~
"Hello *world!" ds" Hello world!
[123+4*56]/2 cs]) (123+456)/2
"Look ma, I'm *HTML!" cs"<q> <q>Look ma, I'm HTML!</q>
if *x>3 { ysW( if ( x>3 ) {
my $str = *whee!; vllllS' my $str = 'whee!';
so for example, Vim lets me just type in which surrounder i want to use. when my cursor is inside a word, i just type
ysiw% and my word is wrapped in %%s. perhaps you could use AHKs
Input command to do something similar, that way you dont have to rely on memory. like, have a global hotkey alt+2 and then press the char you want to wrap with. so something like
Alt+2 followed by
"
good job