You are here: PSPad forum > English discussion forum > How to create some code's pattern

How to create some code's pattern

#1 How to create some code's pattern

Posted by: Semaphore | Date: 07/18/2012 16:01 | IP: IP Logged

Hi,
Sorry for my english.
I'm looking to save some code pattern like
Class xxx extends controller {
public function _construct
{

}
}

or html page template
<head> bla bla</head><body>bla bla</body>

I want re-use this code for saving a lot of time.

thanks for your help

Options: Reply | Quote | Up ^


#2 Re: How to create some code's pattern

Posted by: pspad | Date: 07/18/2012 16:56 | IP: IP Logged

Write your code and select it
Press Ctrl+Alt+Space
Fill in code clip name, eventually shortcut and save

You can manually edit code clip files - menu Settings / Edit Clip definition file or open it directly from PSPad subfolder Context

Code clip structure is described in help

Options: Reply | Quote | Up ^


#3 Re: How to create some code's pattern

Posted by: myf | Date: 07/18/2012 17:18 | IP: IP Logged

Thats what PSPad\Context\*.DEF files are for.

While editing your code ensure you have chosen proper syntax (View > Change Syntax). You can invoke anything you see in corresponding *.DEF file with ctrl+space.

To get your sample snippet working in "interactive" way, your .DEF file should contain something like this:


[Clip Settings]
CursorChar=|
SelectionChar=$
[Macro definition]
%class_name%=@E name
%class_extends%=@E extends," extends "
; ...
[Class | construct class]
Class %class_name%%class_extends% {
public function _construct
{
$|
}
}

then you can write for example " C", press ctrl+spacebar and you should see your snippet. Invoking it should show modal dialog with two inputs and so on (no point in describing it I suppose)

Look at gogogadgetscott.info or press f1 in PSPad and look for "interactive clips".

Options: Reply | Quote | Up ^






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