Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Re-indent on paste

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
.oisyn Posted - Apr 26 2007 : 12:27:15 PM
I like the way how VA X reindents my code when I paste a piece of code inside a code block, when the 'reformant on paste' option is enabled. However, of course it also reformats the code in the clipboard (as that is what the option does), which I don't want because in my case it's always in the correct formatting (and VA X messes this up sometimes). I want it just to reindent it according to the current scope.

So I'd like to request a feature to only reindent a pasted code block, instead of reformatting it completely :)
10   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Sep 18 2007 : 1:19:43 PM
A very interesting idea, I have put in a feature request for this:

case=8930
Old as dirt Posted - Sep 18 2007 : 10:59:40 AM
I know I'm coming in late on this discussion, but I found it with the search because I was wanting a change so that it did the automatic formatting when a comment was present as well as when there were no comments.
It turns out that the behavior is different between dragging a block to where you want it and pasting it from the clipboard. I knew that years ago, but I forgot it. So my problem is solved if I copy the block to the clipboard and paste it where I want it instead of dragging it.
Now for a suggestion: Have a key combination like Ctrl-Shift-V to temporarally reverse the Format after paste option when doing the paste.
sl@sh Posted - May 07 2007 : 04:28:02 AM
While I don't care about changes to the way VA handles indents on insert for code, I really would like VA to keep indentation for blocks of comments!

For example consider a function header like this:
/**
 * function name:    foo
 * ...
 */

or this:
/***********************************************
 function name   : foobar
 parameters      :
                   int            bar
                   void*          foopointer
***********************************************/


When I want to move these function implementations including the header, VA automatically applies the standard reformatting on both the comment block and the code. Formatting the code is fine by me, but formatting the comment block almost always destroys the intended format: the first line is being aligned according to the context (same indentation as previous line) - which is usually ok. The rest of the comment block however gets the same indentation, which means formerly existing indentation-based formatting is completely lost.

Couldn't VA detect comment blocks like the ones above and only apply indentation as appropriate?
RickHodgin Posted - May 04 2007 : 2:04:56 PM
quote:
...this is going to have problems when people copy / paste "uneven" pieces of code...

A word pops to mind: "So?"

In all honesty, who cares? If there was an option to keep all of us from having to manually reindent our own code with our own indentation then what's the big deal? You can pull the tab indent value from the editor settings for the current file type, determine whether or not this new block should be indented relative to where it was inserted or not, and then either adjust everything over by the difference from where it is now to where it needs to be, or do that and also indent by the specified number of spaces.

If you want to address unevenly tabbed/spaced code then you could include a second option like:
"Snap indentation to nearest?"

Which would snap the indentation marking to the nearest multiple of whatever the tab indent size is (even if it's inserted with spaces and not tabs--with tabs it would be easier).

quote:
So I do understand the appeal, but I also understand the scope of the problem.


I don't understand the scope of the problem at all. The code block being inserted exists and has a certain number of characters to the left-most character of the entire block. Just assume that is the left-most character which should be inserted to wherever the nearest indentation should be for the current line.

And if there does happen to be a problem there, then we can do the CTRL+Z trick you're already talking about and manually indent it ourselves anyway -- just like now.

Not only don't I see the problem there, I can't see how helping out in the vast majority of cases wouldn't be a desirable enough trait to include that you could even formulate an argument against it.
feline Posted - May 03 2007 : 10:43:06 AM
While I like the idea, I have the same problem myself occasionally, this is going to have problems when people copy / paste "uneven" pieces of code, like:

{
    {
        {


or anything "similar".

After much arguing with the IDE I just learned to mostly accept its code indenting approach, it was to much work fighting it every step of the way. So I do understand the appeal, but I also understand the scope of the problem. Play with GC for a while, and see if you can make that do *exactly* what you want...
RickHodgin Posted - May 03 2007 : 09:57:12 AM
quote:
...but it's annoying...

Agreed. I have had countless instances where I've had to undo the paste reformatting and then manually indent. If there was a way to determine how far in it should be to the left-most portion of whatever the original source was as it applies in its new block, that would be great.

How about calling it:
"Only indent/align entire block on paste?"
.oisyn Posted - May 03 2007 : 08:10:34 AM
That's what I'm usually doing now, but it's annoying if the codeblock your pasting is a bit large (say, 3+ screens). But I'll think I'll write a "paste and keep selected" macro instead :)
feline Posted - Apr 27 2007 : 12:37:36 PM
What you need to do is paste, then Undo, then select the lines and press Tab or Shift-Tab to indent / unindent them to your hearts desire.

Currently we have no intention of trying to implement code formatting features, that is a whole new job.
.oisyn Posted - Apr 27 2007 : 11:02:06 AM
I know the clipboard isn't affected, that isn't what I meant. I don't want the pasted code to be reformatted completely, I only want that the indentation is changed.

So if the code in my clipboard reads
a
    b
c
        d


And I paste it in the following block:
if (bla)
{
    // paste here
}


I want it to read
if (bla)
{
    a
        b
    c
            d
}

Instead of
if (bla)
{
    a
        b
        c
        d
}


But I thought that VA X was doing the reformatting. If you call the autoformat feature from Visual Studio I recon that what I want isn't possible without fully implementing formatting features yourself :)
feline Posted - Apr 26 2007 : 12:43:11 PM
The clipboard should not be effected. All VA does is asks the IDE to format the code on paste. Since this is done after the paste use Undo once to undo the formatting, you are now free to indent it as you want.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000