Editing tips needed

Support for all customers who have purchased a SAPIEN PowerShell Studio product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
dbaduck
Posts: 3
Joined: Tue Apr 22, 2014 4:26 pm

Editing tips needed

Post by dbaduck » Wed Mar 30, 2016 7:56 am

Product, version and build: 5.2.117
32 or 64 bit version of product: 64
Operating system: Windows 10
32 or 64 bit OS: 64

I just want to see if there is anyone that can tell me if it is possible to do this in editing a script.

I have lines of code that operate on a System.Data.DataTable and the variable is used over and over again adding columns and setting properties. What I would like to know is when you double click on the variable name, you see it get highlighted and then all the variables with the same name highlight below. Is there a way to take advantage of that and replace all of those with a paste? I have copied the new variable name that I want to replace the old one, but I cannot find a way to leverage the fact that they are all the same (I know that I can use Find/Replace, but I want to find out if there is a feature that I can use right in the moment).

Example:

$var1 = New-Object -TypeName System.Data.DataTable
[void]$oldvariableName.Columns.Add("col1", [Int])
[void]$oldvariableName.Columns.Add("col2", [Int])

Now when I double click on $var1 it highlights $var1 and I copy.
Then I double click on $oldvariableName and it highlights it and also puts a sub highlight on all the names below that match. I want to be able to just paste that $var1 that was copied over the top of all the highlighted and sub-highlighted ones without using Find/Replace.

Thanks.

User avatar
davidc
Posts: 5889
Joined: Thu Aug 18, 2011 4:56 am

Re: Editing tips needed

Post by davidc » Wed Mar 30, 2016 9:35 am

You can try using the rename refactoring command by right-clicking on the variable and selecting Rename from the context menu. It will pop up a dialog and you can paste the replacement there.

If you are in a project, the rename refactoring will even work across files, depending on the variable or function.

David
David
SAPIEN Technologies, Inc.

User avatar
davidc
Posts: 5889
Joined: Thu Aug 18, 2011 4:56 am

Re: Editing tips needed

Post by davidc » Wed Mar 30, 2016 9:37 am

If the code is lined up as in your example, you can use block selection [Shift + Alt] to replace multiple lines at once.

David
David
SAPIEN Technologies, Inc.