Announce: SmartCopyPlugin v. 0.2

I've added the ability to my SmartCopyPlugin to automatically escape anything that gets pasted into a Java string literal, along with all the other goodies. It's very handing for pasting large text blocks into Java from non-Java sources. A future version will probably make similar functionality work with XML, HTML and JSP, if I can manage it.

While I've found this plugin very useful in my own development, I've had literally zero feedback on it from anyone. If anyone is using it, let me know. First one to say anything gets priority on features.]]>

Here's the goto:

http://www.intellij.org/twiki/bin/view/Main/SmartCopyPlugin

and the feature list
-


This plugin adds a variety of useful editor actions, enhancing the cut, copy, and paste functionality of IDEA. As of version 0.2, this plugin uses the unsupported Psi interface to get access to IDEA's parse tree, so it could become unstable with any future release, yadda, yadda.

New Actions

Paste As String: Pastes the current clipboard into the editor, wrapping it's contents in double quotes. Any characters not allowed in Java strings are escaped. Newlines are escaped, and also result in breaking the pasted string across lines. Thus pasting the following as a string:



results in:



Additionally, if you have an already existing string that you wish to paste into, this plugin overrides the paste command to do the escaping and breaking. I've found this action is useful for copying in queries from command-line SQL tools into java code. Default key mapping = control-shift-P


Copy-Append: Copies the current selection (or the current line if nothing is selected), appending it to the contents of the current clipboard. Default key mapping = control-shift-C

Cut-Append: Same as Copy-Append, but also deletes the selection. Default key mapping = control-shift-X

Smart Copy: The first time Smart Copy is used, it acts like a standard Copy operation. Subsequent times, it acts as Copy-Append. Paste (including Paste Above) resets the action. This makes it easy to bundle up sequences of copies for one paste. Default key mapping = alt-U

Smart Cut: Same as Smart Copy, but also deletes the selection. Default key mapping = alt-Y

Paste Above: Just like Paste (including auto-reformatting and auto-import), but pastes the contents of the clipboard into the line above the current caret position, rather than over the current selection. Default key mapping = alt-P

5 comments
Comment actions Permalink

Dave,

Sorry to not have given you any feedback but I love the features that you
had and the addition of pre-formatting string into a proper java string is
god-send! Great work

Now about features... since I have priority... I will think of something
for you to do instead of wasting all that time doing that stupid sleeping
;)

Jacques
"Dave Griffith" <dave.griffith@trilogy.com> wrote in message
news:3785757.1037898624486.JavaMail.jrun@is.intellij.net...

I've added the ability to my SmartCopyPlugin to automatically escape

anything that gets pasted into a Java string literal, along with all the
other goodies. It's very handing for pasting large text blocks into Java
from non-Java sources. A future version will probably make similar
functionality work with XML, HTML and JSP, if I can manage it.
>

<whine>While I've found this plugin very useful in my own development,

I've had literally zero feedback on it from anyone. If anyone is using it,
let me know. First one to say anything gets priority on features.</whine>
>

Here's the goto:

>

http://www.intellij.org/twiki/bin/view/Main/SmartCopyPlugin

>

and the feature list
-------------------------------------------------------
This plugin adds a variety of useful editor actions, enhancing the cut,

copy, and paste functionality of IDEA. As of version 0.2, this plugin uses
the unsupported Psi interface to get access to IDEA's parse tree, so it
could become unstable with any future release, yadda, yadda.
>

New Actions

>

Paste As String: Pastes the current clipboard into the editor,

wrapping it's contents in double quotes. Any characters not allowed in Java
strings are escaped. Newlines are escaped, and also result in breaking the
pasted string across lines. Thus pasting the following as a string:
>

Now is the time for "all" good men > to come to the aid of their country.]]>

>

results in:

>

"Now is the time for \"all\" good men\n" + > "\tto come to the aid of their country.\n"]]>

>

Additionally, if you have an already existing string that you wish to

paste into, this plugin overrides the paste command to do the escaping and
breaking. I've found this action is useful for copying in queries from
command-line SQL tools into java code. Default key mapping = control-shift-P
>
>

Copy-Append: Copies the current selection (or the current line if

nothing is selected), appending it to the contents of the current clipboard.
Default key mapping = control-shift-C
>

Cut-Append: Same as Copy-Append, but also deletes the selection.

Default key mapping = control-shift-X
>

Smart Copy: The first time Smart Copy is used, it acts like a

standard Copy operation. Subsequent times, it acts as Copy-Append. Paste
(including Paste Above) resets the action. This makes it easy to bundle up
sequences of copies for one paste. Default key mapping = alt-U
>

Smart Cut: Same as Smart Copy, but also deletes the selection.

Default key mapping = alt-Y
>

Paste Above: Just like Paste (including auto-reformatting and

auto-import), but pastes the contents of the clipboard into the line above
the current caret position, rather than over the current selection. Default
key mapping = alt-P
>
>


0
Comment actions Permalink

Did not take me long to remember some needed features:
1) automatic append on copy and cut when the following copy/cut would
copy/cut a contiguous block. Using the default behavior "if there are no
selection the line is copied or cut", you could copy or cut a bunch of
contiguous lines by just Ctrl-C or Ctrl-X. This is implemented in emacs and
I miss it a few times! Ctrl-X, Ctrl-X would just be line selecting both line
than Ctrl-X. In emacs the act of deleting something puts it in the buffer so
it works also with words and subexpressions not just lines.

2) Have a Copy as Text from java string literal would put in the buffer a
non java string removing escapes and leading/ending " so you can do a full
round trip, outside normal text -> inside java text -> outside normal text.

3) Have an option to have the pasted text rewrapped on the right margin
automatically: breaking in substring combined with +. It might also rebreak
the string if it was already broken at a different column.

Here you go.

Jacques

"Jacques Morel" <jacmorel@yahoo.com> wrote in message
news:arkbcc$d22$1@is.intellij.net...

Dave,

>

Sorry to not have given you any feedback but I love the features that you
had and the addition of pre-formatting string into a proper java string is
god-send! Great work

>

Now about features... since I have priority... I will think of something
for you to do instead of wasting all that time doing that stupid sleeping
;)

>

Jacques
"Dave Griffith" <dave.griffith@trilogy.com> wrote in message
news:3785757.1037898624486.JavaMail.jrun@is.intellij.net...

I've added the ability to my SmartCopyPlugin to automatically escape

anything that gets pasted into a Java string literal, along with all the
other goodies. It's very handing for pasting large text blocks into Java
from non-Java sources. A future version will probably make similar
functionality work with XML, HTML and JSP, if I can manage it.
>

<whine>While I've found this plugin very useful in my own development,

I've had literally zero feedback on it from anyone. If anyone is using

it,

let me know. First one to say anything gets priority on features.</whine>
>

Here's the goto:

>

http://www.intellij.org/twiki/bin/view/Main/SmartCopyPlugin

>

and the feature list
-------------------------------------------------------
This plugin adds a variety of useful editor actions, enhancing the cut,

copy, and paste functionality of IDEA. As of version 0.2, this plugin uses
the unsupported Psi interface to get access to IDEA's parse tree, so it
could become unstable with any future release, yadda, yadda.
>

New Actions

>

Paste As String: Pastes the current clipboard into the editor,

wrapping it's contents in double quotes. Any characters not allowed in

Java

strings are escaped. Newlines are escaped, and also result in breaking the
pasted string across lines. Thus pasting the following as a string:
>

> Now is the time for "all" good men > > to come to the aid of their country.]]>

>

results in:

>

> "Now is the time for \"all\" good men\n" + > > "\tto come to the aid of their country.\n"]]>

>

Additionally, if you have an already existing string that you wish to

paste into, this plugin overrides the paste command to do the escaping and
breaking. I've found this action is useful for copying in queries from
command-line SQL tools into java code. Default key mapping =

control-shift-P

>
>

Copy-Append: Copies the current selection (or the current line if

nothing is selected), appending it to the contents of the current

clipboard.

Default key mapping = control-shift-C
>

Cut-Append: Same as Copy-Append, but also deletes the selection.

Default key mapping = control-shift-X
>

Smart Copy: The first time Smart Copy is used, it acts like a

standard Copy operation. Subsequent times, it acts as Copy-Append. Paste
(including Paste Above) resets the action. This makes it easy to bundle up
sequences of copies for one paste. Default key mapping = alt-U
>

Smart Cut: Same as Smart Copy, but also deletes the selection.

Default key mapping = alt-Y
>

Paste Above: Just like Paste (including auto-reformatting and

auto-import), but pastes the contents of the clipboard into the line above
the current caret position, rather than over the current selection.

Default

key mapping = alt-P
>
>

>
>


0
Comment actions Permalink

Hi

Your plugin is cool. I can use the feature to copy strings into javacode. Usually it's as you mention SQL code from a SQL prompt.

The new commands smart-copy is cool, but it takes a while to get used to the new keyboard shortcuts. altu, altp but I guess after a while you get used to it. Especially the smart-copy is cool since you sometimes copy a couple of lines from other files and you only need one paste command, and not to find it from the clipboard history (ctrlshiftv)


Idea:
Since it can be a little hard in the start to remeber all the new keyboard shortcuts, it would be nice to have the actions in the right-click menu, and in the Edit menu.


/Claus

0
Comment actions Permalink


Thanks! Glad you like it. It would have been a lot more difficult without PsiViewer (and my next plugin I'm working on would be impossible).

Did not take me long to remember some needed
features:
1) automatic append on copy and cut when the
following copy/cut would
copy/cut a contiguous block. Using the default
behavior "if there are no
selection the line is copied or cut", you could copy
or cut a bunch of
contiguous lines by just Ctrl-C or Ctrl-X. This is
implemented in emacs and
I miss it a few times! Ctrl-X, Ctrl-X would just be
line selecting both line
than Ctrl-X. In emacs the act of deleting something
puts it in the buffer so
it works also with words and subexpressions not just
lines.


"Smart Cut" basically does this (for lines), but overriding standard cut to do this in case of contiguous selections should be doable.


2) Have a Copy as Text from java string literal would
put in the buffer a
non java string removing escapes and leading/ending "
so you can do a full
round trip, outside normal text -> inside java text
-> outside normal text.


Ooooh. Yeah, I can definitely see value in this.


3) Have an option to have the pasted text rewrapped
on the right margin
automatically: breaking in substring combined with +.
It might also rebreak
the string if it was already broken at a different
column.


Hmm. I think I'll wait too see if any wrapping support gets included in Aurora (hint, hint), before tackling this one.


0
Comment actions Permalink


Idea:
Since it can be a little hard in the start to remeber
all the new keyboard shortcuts, it would be nice to
have the actions in the right-click menu, and in the
Edit menu.


Great idea. This'll be in 0.3.

--Dave

0

Please sign in to leave a comment.