0

In my prototyping I'm doing much copy&pasting from .js file to .html where the .js file needs wrapped text in a string. So I find myself wasting time "plussing/unplussing" (if that are even real words) my html. It's a pain.

example: I'd like to "copy&paste"

<i>jabadaba</i>

and get

+'<i>jabadaba</i>'

and viceversa if it goes ;)

Now, I'm using IntelliJ IDEA on Ubuntu(linux) as the editor of choice but anything that solves problem would be great. Just some simple tool or something...tnx.

3 Answers 3

0

Consider using coffeescript. It's a language which compiles to javascript. It has a learning curve, but is great for solving such problems:

http://coffeescript.org/#strings

1
  • Now I have a reason (for myself) why migrate to CoffeeScript. I did some minor work with it in the past and liked it. I'll go with this approach. Don't know why I didn't thought of this sooner ;) Tnx. Dec 22, 2012 at 8:51
0

Here is a quick solution.

  1. Replace all single quote (') with double quotes ("). Ideally it should not break anything but just verify.

  2. Replace all the \n with \n in a regex capable find/replace editor. Eclipse works.

  3. Now you have all the code in single line. Just put single quotes around it and you are ready to transport it to JS

  4. In JS: Do line break where deemed fit by doing ' + '

0

EDIT: IntelliJ has macros. Record yourself doing it once then play it back http://www.jetbrains.com/idea/webhelp/using-macros-in-the-editor.html


a lot of editors nowadays support Column edit or multiple cursors, which would really help in what you want to achieve, but I am not sure if IntelliJ is one of them however.

Have a look at Sublime Text 2, its free to evaluate and offers a wealth of tools

To select a column in Sublime Text 2, just drag using the Middle mouse button. To place multiple cursors, hold Ctrl, while clicking on where you want the cursors to be placed

If you want a more automated approach, you can try writing a simple bash script, but I am no expert on bash scripting, so I cant help you there

1
  • I know for IntelliJ macros and plugins. Even tried few back in time but nothing that would meed needs. It's just weird that functionality like this doesn't come boxed in product - it seems basic..but ok their choice. Dec 22, 2012 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.