VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Secure Shell (https://forums.vandyke.com/forumdisplay.php?f=15)
-   -   Feature Request: Paste Special (https://forums.vandyke.com/showthread.php?t=10349)

dhahn 03-14-2012 09:50 AM

Feature Request: Paste Special
 
I'm using version 6.6.3 (x64 build 412). I'd like to make a request for a "paste special" command that would convert X number of spaces to a tab in whatever text you are pasting.

Somewhere in settings, the user could specify the number of spaces that would be replaced.

Here's my use case. I'm often doing a lot of copying and pasting from one UNIX vi text file to another. When I do, it appears my tabs get converted to spaces when I paste. Something that starts...

if ($foo == 1) {
[TAB]if ($bar == 1 ) {
[TAB][TAB]print "Baz!";
[TAB]}
}

...becomes the following when copy/pasted using SecureCRT:

if ($foo == 1) {
[SPACE][SPACE][SPACE][SPACE][SPACE]if ($bar == 1 ) {
[SPACE][SPACE][SPACE][SPACE][SPACE][SPACE][SPACE][SPACE][SPACE][SPACE]print "Baz!";
[SPACE][SPACE][SPACE][SPACE][SPACE]}
}

By using a Paste Sepcial command, it would see five (in my example above) spaces, and make each of those a tab.

--drew

rtb 03-14-2012 10:33 AM

Hi Drew,

Thanks for the suggestion. I have created a feature request in our SecureCRT enhancement database to add this capability. Should a future release of SecureCRT have the ability to convert spaces received from vi to tabs that were originally typed, we will post to this forum thread.

If you would like to be notified directly, please complete and submit the form at the following location:
Submit Feature Request
In the meantime, the following forum thread discusses using a script as a workaround:
http://forums.vandyke.com/showthread.php?t=8756
There are two scripts that should work. A more complex example is called ConvertClipboard--LF-CR--Space-Tab.vbs.ext (found in post #3), and the simplified version is called ConvertSpacesToTabsWhenCopying.vbs.txt (found in post #6).

Are you able to use the example scripts to accomplish your goal?

MrC 03-14-2012 12:27 PM

Drew, not to distract from your request to VanDyke...

Long ago, I created vi macros to allow yanking / pulling of text from one file to another. If you're interested, I'll post them for you. They work by you setting the cursor to the first line of the copy, typing "ma" (mark 'a') and moving the the cursor to the last line, and then typing "(" - this yanks the text between the 'a' mark and the current line, placing it into a temporary file.

In another vi'd file, simply place the cursor at the location, and type ')' to put the text.

This works on a single system, or of course, NFS'd file system. I still use them today, because they are simple.

dhahn 03-15-2012 08:30 AM

That would be great if you would post it. Thanks.

The other thing I've done, when I know it's safe, is issue a regex within vi to convert 8 spaces to a tab:

Code:

:1,19s/        /\t/g
It works, but it would be more elegant if it was built into SecureCRT.

--drew

rtb 03-15-2012 11:09 AM

Hi Drew,

Thanks for the update. We will post to this thread if a future release of SecureCRT has the ability to convert the spaces to tabs.

MrC 03-15-2012 11:44 AM

Here's the idea in its simplest form for *nix platforms:

Code:

map ( :'a,.w!~/.vimscratch
map ) :r ~/.vimscratch

Enter it into your .exrc or .vimrc and restart vi/vim (or re-load the init file). Use by going to the first line you want copied, mark with a (keystroke: ma) move to the last line, and then hit ( to push the lines to the scratch file. Go to your new file on the same machine, move to point one line above where you want the lines to be placed, and enter ).

Re: your tabs substitution, type:

:help retab

in vim.


All times are GMT -6. The time now is 05:26 AM.