Sublime Forum

Multiple lines of user input

#1

Is it possible to get multiple lines of user input using some sort of dialog? I’ve looked through the API documentation and all I see related to user input is Window.show_quick_panel and Window.show_input_panel. If I understand them correctly, the first lets the user choose from a list (like an HTML select) and the other lets the user input one line of text (like an HTML text input). I’m wanting the user to input multiple lines like an HTML textarea. Possible? If so, could someone point me to an example or documenation?

I’m trying to implement a search and replace that handles multiple pairs at a time. In a Rails project, I often find myself needing to replace constants, class names, and instances over and over, and instead of running three searches, I’d prefer to run just one. When I used TextMate, I created a command thing to pop up an input dialog into which I entered all of my pairs. I’d like to do something similar in ST2. As an example, I might do something like:

CAT=>DOG
Cat=>Dog
cat=>dog

I’d use regular expressions if I knew how to have the replacement retain the case of the subject being replaced.

Thanks much.

0 Likes

#2

The “Replace” panel has a button called “preserve case” that will do what you’re looking for.

0 Likes

#3

Thanks, C0D312. That gets me most of the way there. Now my only hurdle is when plural forms differ:

place => county
places => counties

But the preserve case option goes a very long way indeed!

Peace.

0 Likes

#4

Well, not one to drop something I have in mind to do, I kept whacking at this problem. In the past, I have saved these find/replace pairs to a file so they can be reused. I decided there was no harm in just using that file as the input/display of what the find/replace pairs are. So, after a couple of hours of twiddling around, I came up with something that I think will work well enough for me, and I thought I’d share it just in case it’s of interest to anyone else (either for its intended use or an example of how to do something).

gist.github.com/1519543

Since I’m pretty new to Python, I’d appreciate any suggestions on how to make the code better.

Peace.

0 Likes