Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

migrated from stackoverflow.com Dec 21 '12 at 13:32

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 0 down vote accepted

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

share|improve this answer
    
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. –  Alan Ristić Dec 22 '12 at 8:51
add comment

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 ' + '

share|improve this answer
add comment

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

share|improve this answer
    
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. –  Alan Ristić Dec 22 '12 at 8:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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