zizhongyan / StataImproved

Improved Stata Editor for macOS : a sublime text 3 plugin
MIT License
48 stars 15 forks source link

make "/ *word */" to "word" #22

Closed fredericky123 closed 1 year ago

fredericky123 commented 3 years ago

Right now, select any word, press cmd+/, it will become / word /. We also need the opposite function of this, can you set "press cmd+\",it will make "/ word /" to "word".

Or you can set the key to "cmd+shift+/".

Thanks a lot!

zizhongyan commented 3 years ago

This is really a good point. I have tried a bit. But to be honest, I still did not find a way to remove the toggle / word / within the capacity of the keymap function of sublime.

zizhongyan commented 3 years ago

Well. After a cup of coffee, I have added what you described to the package.

Now we can: Select any word, press $ to make it as ${word}. And select ${word}, press $ to make it as word.

Select any word, press cmd+ to make the selected word toggled. And press it again to make toggled word to original word.

I did not add this function to local macro because I think when wrting loops or Stata programs, it is very often in practice to use local of locals, e.g `word'' and ```word''' . So one might not wish to remove the quotation marks fromword'.

The package should be updated to package control in about 1-2 hours.

zizhongyan commented 3 years ago

Thank you very much

rorymullen commented 3 years ago

This doesn't seem to be working for me.

If I select word and press $ I get the desired behavior, but if I select ${word} and press $ I get ${${word}}.

Likewise with comments. If I select word and press cmd+/ I get /* word */, as expected. If I select /* word */ and press cmd+/ I get /*/* word */*/.

I'm on a mac running Sublime Text 4 in MacOS Monterey...

fredericky123 commented 3 years ago

This doesn't seem to be working for me.

If I select word and press $ I get the desired behavior, but if I select ${word} and press $ I get ${${word}}.

Likewise with comments. If I select word and press cmd+/ I get /* word */, as expected. If I select /* word */ and press cmd+/ I get /*/* word */*/.

I'm on a mac running Sublime Text 4 in MacOS Monterey...

This works for me. I guess you include some spaces when select / word / or ${word}, please pay attention to that.

rorymullen commented 3 years ago

Uninstalled and reinstalled StatsImproved and now working like a charm in ST4 in MacOS Monterey :)

However, and this is admittedly nit-picky, reversing comments still behaves unexpectedly in one particular case: if my curser is next to word but word is unselected, then cmd+/ yields /* word */ as described in case 2 here, but if my curser is next to /* word */ and /* word */ is not selected, then cmd+/ yields /* word /* */ */ instead of word.

I know this is super nit-picky, but given the default behavior of cmd+/ implemented in cases 2 and 3 described here, I think the current comment reversal behavior is suboptimal.