You are here: PSPad forum > English discussion forum > Also assign Shift+Backspace to DeleteLastChar?

Also assign Shift+Backspace to DeleteLastChar?

#1 Also assign Shift+Backspace to DeleteLastChar?

Posted by: lphilpot01 | Date: 2022-11-29 03:50 | IP: IP Logged

Is there a way to have Backspace AND Shift+Backspace both assigned to DeleteLastChar? It's just sloppy typing on my part but I find that I sometimes have the Shift key down when I'm backspacing and it goes nowhere when that happens. However, there's only one shortcut assignable to DelteLastChar.

Is there a way to assign more than one?

Thanks.

--
Retired ... finally!

Options: Reply | Quote | Up ^


#2 Re: Also assign Shift+Backspace to DeleteLastChar?

Posted by: pspad | Date: 2022-11-29 08:17 | IP: IP Logged

Hello

You can't assign 2 shortcuts to one command, but it's possible to write simple script with your shortcut, what will call delete last char.
Prerequisities:
32b PSpad version
Scripting is enabled in the Program settings / System integration

Open new file with .VBS (visual basic script) extension
Put following content into your file:

Sub ShiftBckSpace
If (editorsCount = 0) Then
Exit Sub
End If
Set editor = newEditor()
editor.assignActiveEditor
editor.command(ecDeleteLastChar)
end sub

menu items
sub Init
addMenuItem "Shift+BackSpace","", "ShiftBckSpace", "Shift+BkSp"
end sub

Save this file into PSpad subfolder:
.\Script\VBScript
After recompilation from the menu Script or new PSpad start you should see in the menu Script new item Shift+BackSpace and your Shift+BackSpace should delete last char same as BackSpace

Options: Reply | Quote | Up ^


#3 Re: Also assign Shift+Backspace to DeleteLastChar?

Posted by: lphilpot01 | Date: 2022-12-02 03:08 | IP: IP Logged

Pre-reqs are met, but with the code copied verbatim, I get these two runtime errors:
Description: Variable is undefined "menu"
Description: Variable is undefined "items"

So I assumed the line "menu items" was meant to be a comment and made it one (i.e., 'menu items).

Then I get this error:
Module name "" isn't unique

I commented out the default "option explicit" line (from the VBscript template) thinking it might relax the syntax requirements, but I still get the same error. Does it need a specific module name?

Sorry, but it's been YEARS since I last looked at VBscript and only briefly then. If it was a Bash script I could probably debug it myself. Probably... smiling smiley

Thanks!

--
Retired ... finally!

Options: Reply | Quote | Up ^


#4 Re: Also assign Shift+Backspace to DeleteLastChar?

Posted by: lphilpot01 | Date: 2022-12-02 03:15 | IP: IP Logged

Small update...

After looking at the other script I added a line Const module_name = "ShiftBackspace", which fixed the last error. But when I try to use Shift+Backspace, I get this runtime error:

Module: ShiftBackspace
Line: 11 Pos: 1
Description: Invalid procedure call or argument
'editor.command'

Maybe I've introduced a namespace issue now? At any rate, I don't know VBscript and obviously I'm not fixing it, so I'll wait for the real answer.

Thanks!

--
Retired ... finally!

Options: Reply | Quote | Up ^


#5 Re: Also assign Shift+Backspace to DeleteLastChar?

Posted by: pspad | Date: 2022-12-02 05:06 | IP: IP Logged

Hello, change it to:
editor.command "ecDeleteLastChar"

Options: Reply | Quote | Up ^


#6 Re: Also assign Shift+Backspace to DeleteLastChar?

Posted by: lphilpot01 | Date: 2022-12-02 15:31 | IP: IP Logged

That did it. I also added "Dim editor" at the top to resolve one other error but it's working now.

One question - Is there a place (maybe under %APPDATA%) I can put this script where it won't be affected by upgrades? There's no scripts folder by default under my profile.

Thanks!

--
Retired ... finally!

Options: Reply | Quote | Up ^


#7 Re: Also assign Shift+Backspace to DeleteLastChar?

Posted by: pspad | Date: 2022-12-02 18:10 | IP: IP Logged

Your script, if you create new file won't be attached by updates.
User defined folders are in ToDo but not finished yet.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR