Lazarus IDE Tools/zh CN

From Lazarus wiki
Revision as of 04:31, 13 February 2014 by Wangyouworld (talk | contribs) (代码自动完成)

Deutsch (de) English (en) español (es) suomi (fi) français (fr) 日本語 (ja) 한국어 (ko) Nederlands (nl) português (pt) русский (ru) slovenčina (sk) 中文(中国大陆)‎ (zh_CN)

Lazarus IDE 工具

概述

IDE使用了Pascal源码解析和编辑工具库,被称为“codetools(代码工具)”。工具提供的功能像查找声明、代码完成、提取、移动插入和美化Pascal。这些函数可以节省你很多时间,你可以在编辑器选项中对它们进行自定义配置。

因为它们的工作时解析FPC、Delphi和Kylix代码。它们不需要编译单元,也不是一个安装了Borland的编译器。你可以在同一时间编辑Delphi和FPC代码。你可以使用不同版本的Delphi和FPC。这使得移植Delphi代码变得容易很多。

IDE 快捷键列表

声明跳转 Ctrl+点击 or Alt+ (跳转到声明的类型或变量)
方法跳转 Ctrl+ Shift+ (在定义部分和实现部分进行切换。看见一个定义,就可以用快键方式,直接找到它的实现部分。)
代码模板 Ctrl+J
Syncro 编辑(同步编辑) Ctrl+J (需要选择文本)
类提示 Ctrl+ Shift+C
标识符提示 Ctrl+空格
关键字提示 Ctrl+W
参数提示 Ctrl+ Shift+空格
渐进式搜索 Ctrl+E

方法跳转

要在过程体(begin..end)与过程定义(procedure 过程名)间跳转,使用 Ctrl+ Shift+.

示例:

interface

procedure DoSomething; // 过程定义
 
implementation
 
procedure DoSomething; // 过程体
begin
end;

如果光标在过程体,当你按Ctrl+ Shift+时,会跳转到其定义,再次按Ctrl+ Shift+会跳转到过程体;如此循环。

在方法间(类中的过程)也是如此。

注意: 方法跳转,将跳转到具有相同名称和参数列表的地方,如果没有,它将跳到最佳匹配的地方,并将光标定位在第一个上面。(对于Delphians:Delphi不能做到这一点。)

例如,不同参数类型的过程:

interface

procedure DoSomething(p: char); // 过程定义

implementation
  
procedure DoSomething(p: string); // 过程主体
begin
end;

自定义跳转会在'string'处定位光标,这可用于重命名方法或改变参数。

如:
你更名'DoSomething' 为 'MakeIt':

interface

procedure MakeIt; // 过程定义

implementation

procedure DoSomething; // 过程主体
begin
end;

Then you jump from MakeIt to the body. The IDE searches for a fitting body, does not find one, and hence searches for a candidate. Since you renamed only one procedure there is exactly one body without definition (DoSomething) and so it will jump to DoSomething and position the cursor right on 'DoSomething'. Then you can simply rename it there too. This works for parameters as well.

引入文件

引入文件是使用{$I 文件名} 或 {$INCLUDE 文件名}编译指令。Lazarus和FPC大量采用它,以减少冗余,为考虑平台兼容性,可以使用{$IFDEF}结构。

Contrary to Delphi, the Lazarus IDE has full support for include files. You can for example jump from the method in the .pas file to the method body in the include file. All codetools like code completion consider include files as special bounds.

For instance: When code completion adds a new method body behind another method body, it keeps them both in the same file. This way you can put whole class implementations in include files, like the LCL does for nearly all controls.

But there is a newbie trap: If you open an include file for the first time and try method jumping or find declaration you will get an error. The IDE does not know to which unit the include file belongs. You must open the unit first.

As soon as the IDE parses the unit, it will parse the include directives there and the IDE will remember this relationship. It saves this information on exit and on project save to ~/.lazarus/includelinks.xml. The next time you open this include file and jump or do a find declaration, the IDE will internally open the unit and the jump will work. You can also hint the IDE by putting

{%mainunit yourunit.pas} 

on the top of yourinclude.inc.

This mechanism has of course limits. Some include files are included twice or more. For example: lcl/include/winapih.inc.

Jumping from the procedure/method definitions in this include file to the bodies depends on your last actions. If you worked on lcl/lclintf.pp the IDE will jump to winapi.inc. If you worked on lcl/interfacebase.pp, then it will jump to lcl/include/interfacebase.inc (or one of the other include files). If you are working on both, then you can get confused. ;)

代码模板

代码模板将标识符转换为文本或代码片段。

默认快捷键是Ctrl+J。输入一个标识符,之后按Ctrl+J键将会替换该标识符为选定的内容。代码模板可以在“工具”菜单->“选项“->“代码工具”里设置。

如,在标识符classf后按Ctrl+Jclassf将被替换为:

T = class(T)
private

public
  constructor Create;
  destructor Destroy; override;
end;

并且光标在T后面。你可以将光标定位在空白位置(而不是标识符那里),按下 Ctrl+J键,将显示代码模板列表。选择一个,将返回选择的代码模板。

输入b之后,按Ctrl+J键,将显示 begin..end; 块。

参数提示

显示参数提示。

例如:

Canvas.FillRect();

将光标置于括号中,按Ctrl+ Shift+space键,将显示FillRect的参数提示信息。

渐进式搜索

渐进式搜索,按Ctrl+E,输入搜索的文本,编辑器会高亮所有搜索到的。

  • 例如,输入e,将搜索并高亮显示所有e的匹配项。
  • 然后,输入t ,将突出显示所有匹配et的文本。
  • 跳转到下一个匹配项,按 F3或(Ctrl+E);跳转到上一匹配项,按 Shift+F3
  • ← Backspace 删除最后一个字符。
  • 停止搜索,可以按 Enter键,或者在代码编辑器中点击鼠标。
  • You can resume the last search by pressing Ctrl+e a second time, immediately after you started incr-search with Ctrl+e. that is while the search term is still empty.
  • Ctrl+V键,粘贴剪贴板中的内容到当前搜索(因为lazarus 0.9.27 r19824)。

注意:快速搜索与渐进式搜索的标识符

  • Place text cursor on identifier (do not select anything) 将光标放在标识符处(不要选择任何内容)。
  • Ctrl+C键,将复制选择的标识符到剪贴板。
  • Ctrl+E键,开始渐进式搜索。
  • Ctrl+V键,搜索标识符(自0.9.27)。
  • F3,向下搜索, Shift+F3向下搜索。
  • 使用任意键(如,光标左、右键)来终止搜索。

Syncro 编辑(同步编辑)

Syncro Edit(同步编辑)可以让你在同一时间同步编辑所有匹配到的内容。你简单的在一个地方编辑,所有匹配的内容也会同步更新。


它适用于所有选择区域的文本:

  • 选择文本块。
  • Ctrl+J或,点击编辑左侧显示的“编辑图标”(SyncroEditIcon.png)。按Tab 键,选择要编辑的内容。
  • 输入新内容。
  • Esc键完成编辑。

这里有动画演示

Note-icon.png

Note: Ctrl+J也是代码模板的快捷键,如果你选择的不是文本块的话。

查找下一个/上一个出现的单词

这两个功能,可以在源代码编辑器的弹出菜单中找到:

  • 源代码编辑器 / 弹出菜单 / 查找 / 查找下一个发现的词
  • 源代码编辑器 / 弹出菜单 / 查找 / 查找前一个发现的词

And you can assign them shortcuts in the editor options.你也可以在查找菜单中,找到相应菜单项,它与其功能相同,当然也可以使用快捷键。

代码自动完成

代码自动完成,可以在“编辑”菜单->“自动完成代码”,或按Ctrl+ Shift+C键。(新版的Lazarus,在“Source”菜单->“自动完成代码”)

对于Delphians:

Delphi的“代码完成”,按Ctrl+Space将显示标识符列表。在Lazarus中称为“标识符提示”。

代码自动完成,有多种强大功能:

  • 类完成:自动完成属性,在方法体中增加/更新私有变量或私有方法。
  • 前向引用过程完成: 添加过程体。
  • 事件赋值完成:完成事件赋值,并增加了方法定义和主体。
  • 变量声明完成:增加了局部变量定义。
  • 过程调用完成:添加新过程。
  • 反转过程完成:添加过程/函数体声明。
  • 反转类完成:添加了方法体声明。

这个功能的使用,取决于编辑器中光标的位置,下面进行说明。

类自动完成

The most powerful code completion feature is "Class Completion". You write a class, add the methods and properties and Code Completion will add the method bodies, the property access methods/variables and the private variables.

For example: Create a class (see Code Templates to save you some type work):

TExample = class(TObject)
public
  constructor Create;
  destructor Destroy; override;
end;

Position the cursor somewhere in the class and press Ctrl+ Shift+C. This will create the method missing bodies and move the cursor to the first created method body, so you can just start writing the class code:

{ TExample }

constructor TExample.Create;
begin
  |
end;

destructor TExample.Destroy;
begin
  inherited Destroy;
end;

Note: The '|' is the cursor and is not added.

Hint: You can jump between a method and its body with Ctrl+ Shift+.

You can see, that the IDE added the 'inherited Destroy' call too. This is done, if there is an 'override' keyword in the class definition.

Now add a method DoSomething:

TExample = class(TObject)
public
  constructor Create;
  procedure DoSomething(i: integer);
  destructor Destroy; override;
end;

Then press Ctrl+ Shift+C and the IDE will add

procedure TExample.DoSomething(i: integer);
begin
  |
end;

You can see, that the new method body is inserted between Create and Destroy, exactly as in the class definition. This way the bodies keep the same logical ordering as you define. You can define the insertion policy in Environment > Codetools Options -> Code Creation.

Complete Properties
Add a property AnInteger:

TExample = class(TObject)
public
  constructor Create;
  procedure DoSomething(i: integer);
  destructor Destroy; override;
  property AnInteger: Integer;
end;

Press Ctrl+Shift+C and you will get:

procedure TExample.SetAnInteger(const AValue: integer);
begin
  |if FAnInteger=AValue then exit;
  FAnInteger:=AValue;
end;

The code completion has added a Write access modifier and added some common code. Jump to the class with Ctrl+ Shift+ to see the new class:

TExample = class(TObject)
private
  FAnInteger: integer;
  procedure SetAnInteger(const AValue: integer);
public
  constructor Create;
  procedure DoSomething(i: integer);
  destructor Destroy; override;
  property AnInteger: integer read FAnInteger write SetAnInteger;
end;

The property was extended by a Read and Write access modifier. The class got the new section 'private' with a Variable 'FAnInteger' and the method 'SetAnInteger'. It is a common Delphi style rule to prepend private variables with an 'F' and the write method with a 'Set'. If you don't like that, you can change this in Environment > Codetools Options -> Code Creation.

Creating a read only property:

property PropName: PropType read;

Will be expanded to

property PropName: PropType read FPropName;

Creating a write only property:

 property PropName: PropType write;

Will be expanded to

property PropName: PropType write SetPropName;

Creating a read only property with a Read method:

property PropName: PropType read GetPropName;

Will be kept and a GetPropName function will be added:

function GetpropName: PropType;

Creating a property with a stored modifier:

property PropName: PropType stored;

Will be expanded to

property PropName: PropType read FPropName write SetPropName stored PropNameIsStored;

Because stored is used for streaming read and write modifiers are automatically added as well.

Hint: Identifier completion also recognizes incomplete properties and will suggest the default names. For example:

property PropName: PropType read |;

Place the cursor one space behind the 'read' keyword and press Ctrl+Space for the identifier completion. It will present you the variable 'FPropName' and the procedure 'SetPropName'.

前向引用自动完成

"Forward Procedure Completion" is part of the Code Completion and adds missing procedure bodies. It is invoked, when the cursor is on a forward defined procedure.

For example: Add a new procedure to the interface section:

procedure DoSomething;

Place the cursor on it and press Ctrl+ Shift+C for code completion. It will create in the implementation section:

procedure DoSomething;
begin
  |
end;

Hint: You can jump between a procedure definition and its body with Ctrl+ Shift+.

The new procedure body will be added in front of the class methods. If there are already some procedures in the interface the IDE tries to keep the ordering. For example:

 procedure Proc1;
 procedure Proc2; // new proc
 procedure Proc3;

If the bodies of Proc1 and Proc3 already exists, then the Proc2 body will be inserted between the bodies of Proc1 and Proc3. This behaviour can be setup in Environment > Codetools Options -> Code Creation.

Multiple procedures:

procedure Proc1_Old; // body exists
procedure Proc2_New; // body does not exists
procedure Proc3_New; //  "
procedure Proc4_New; //  "
procedure Proc5_Old; // body exists

Code Completion will add all 3 procedure bodies (Proc2_New, Proc3_New, Proc4_New).

Why calling it "Forward Procedure Completion"?

Because it does not only work for procedures defined in the interface, but for procedures with the "forward" modifier as well. And because the codetools treats procedures in the interface as having an implicit 'forward' modifier.

事件赋值自动完成

"Event Assignment Completion" is part of the Code Completion and completes a single Event:=| statement. It is invoked, when the cursor is behind an assignment to an event.

For example: In a method, say the FormCreate event, add a line 'OnPaint:=':

procedure TForm1.Form1Create(Sender: TObject);
begin
  OnPaint:=|
end;

The '|' is the cursor and should not be typed. Then press Ctrl+Shift+C for code completion. The statement will be completed to

OnPaint:=@Form1Paint;

A new method Form1Paint will be added to the TForm1 class. Then class completion is started and you get:

procedure TForm1.Form1Paint(Sender: TObject);
begin
  |
end;

This works just like adding methods in the object inspector.

Note:
You must place the cursor behind the ':=' assignment operator. If you place the cursor on the identifier (e.g. OnPaint) code completion will invoke "Local Variable Completion", which fails, because OnPaint is already defined.

Hint:
You can define the new method name by yourself. For example:

 OnPaint:=@ThePaintMethod;

变量声明自动完成

"Variable Declaration Completion" is part of the Code Completion and adds a local variable definition for a Identifier:=Term; statement. It is invoked, when the cursor is on the identifier of an assignment or a parameter.

For example:

procedure TForm1.Form1Create(Sender: TObject);
begin
  i:=3;
end;

Place the cursor on the 'i' or just behind it. Then press Ctrl+ Shift+C for code completion and you will get:

procedure TForm1.Form1Create(Sender: TObject);
var
  i: Integer;
begin
  i:=3;
end;

The codetools first checks, if the identifier 'i' is already defined and if not it will add the declaration 'var i: integer;'. The type of the identifier is guessed from the term right to the assignment ':=' operator. Numbers like the 3 defaults to Integer.

Another example:

type
  TWhere = (Behind, Middle, InFront);
 
  procedure TForm1.Form1Create(Sender: TObject);
  var
    a: array[TWhere] of char;
  begin
    for Where:=Low(a) to High(a) do writeln(a[Where]);
  end;

Place the cursor on 'Where' and press Ctrl+ Shift+C for code completion. You get:

  procedure TForm1.Form1Create(Sender: TObject);
  var
    a: array[TWhere] of char;
    Where: TWhere;
  begin
    for Where:=Low(a) to High(a) do writeln(a[Where]);
  end;

Since 0.9.11 Lazarus also completes parameters. For example

  procedure TForm1.FormPaint(Sender: TObject);
  begin
    with Canvas do begin
      Line(x1,y1,x2,y2);
    end;
  end;

Place the cursor on 'x1' and press Ctrl+ Shift+C for code completion. You get:

  procedure TForm1.FormPaint(Sender: TObject);
  var
    x1: integer;
  begin
    with Canvas do begin
      Line(x1,y1,x2,y2);
    end;
  end;

过程调用自动完成

Code completion can create a new procedure from a call statement itself.

Assume you just wrote the statement "DoSomething(Width);"

procedure SomeProcedure;
var
  Width: integer;
begin
  Width:=3;
  DoSomething(Width);
end;

Position the cursor over the identifier "DoSomething" and press Ctrl+ Shift+C to get:

procedure DoSomething(aWidth: LongInt);
begin

end;

procedure SomeProcedure;
var
  Width: integer;
begin
  Width:=3;
  DoSomething(Width);
end;

It does not yet create functions nor methods.

反转类自动完成

"Reversed Class Completion" is part of the Code Completion and adds a private method declaration for the current method body. It is invoked, when the cursor is in a method body, not yet defined in the class. This feature is available since Lazarus 0.9.21.

For example:

 procedure TForm1.DoSomething(Sender: TObject);
 begin
 end;

The method DoSomething is not yet declared in TForm1. Press Ctrl+ Shift+C and the IDE will add "procedure DoSomething(Sender: TObject);" to the private methods of TForm1.

For Delphians: Class completion works under Lazarus always in one way: From class interface to implementation or backwards/reversed from class implementation to interface. Delphi always invokes both directions. The Delphi way has the disadvantage, that if a typo will easily create a new method stub without noticing.

注释和代码自动完成

Code completion tries to keep comments where they belong. For example:

 FList: TList; // list of TComponent
 FInt: integer;

When inserting a new variable between FList and FInt, the comment is kept in the FList line. Same is true for

 FList: TList; { list of TComponent
   This is a comment over several lines, starting
   in the FList line, so codetools assumes it belongs 
   to the FLIst line and will not break this 
   relationship. Code is inserted behind the comment. }
 FInt: integer;

If the comment starts in the next line, then it will be treated as if it belongs to the code below. For example:

 FList: TList; // list of TComponent
   { This comment belongs to the statement below. 
     New code is inserted above this comment and 
     behind the comment of the FList line. }
 FInt: integer;

方法更新

Normally class completion will add all missing method bodies. (Since 0.9.27) But if exactly one method differ between class and bodies then the method body is updated. For example: You have a method DoSomething.

  public
    procedure DoSomething;
  end;

procedure TForm.DoSomething;
begin
end;

Now add a parameter:

  public
    procedure DoSomething(i: integer);
  end;

and invoke Code Completion (Ctrl+ Shift+C). The method body will be updated and the new parameter will be copied:

procedure TForm.DoSomething(i: integer);
begin
end;

Refactoring

Invert Assignments

Abstract
 : "Invert Assignments" takes some selected pascal statements and inverts all assignments from this code. This tool is usefull for transforming a "save" code to a "load" one and inverse operation.

Example:

procedure DoSomething;
begin
  AValueStudio:= BValueStudio;
  AValueAppartment :=BValueAppartment;
  AValueHouse:=BValueHouse;
end;

Select the lines with assignments (between begin and end) and do Invert Assignments. All assignments will be inverted and identation will be add automatically. For example:

Result:

procedure DoSomething;
begin
  BValueStudio     := AValueStudio;
  BValueAppartment := AValueAppartment;
  BValueHouse      := AValueHouse;
end;

Enclose Selection

Select some text and invoke it. A dialog will popup where you can select if the selection should be enclosed into try..finally or many other common blocks.

Rename Identifier

Place the cursor on an identifier and invoke it. A dialog will appear, where you can setup the search scope and the new name.

  • It will rename all occurences and only those that actually use this declaration. That means it does not rename declarations with the same name.
  • And it will first check for name conflicts.
  • Limits: It only works on pascal sources, does not yet rename files nor adapt lfm/lrs files nor lazdoc files.

Find Identifier References

Place the cursor on an identifier and invoke it. A dialog will appear, where you can setup the search scope. The IDE will then search for all occurences and only those that actually use this declaration. That means it does not show other declarations with the same name.

Show abstract methods

This feature lists and auto completes virtual, abstracts methods that need to be implemented. Place the cursor on a class declaration and invoke it. If there are missing abstract methods a dialog will appear listing them. Select the methods to implement and the IDE creates the method stubs.

Extract Procedure

See Extract Procedure

Find Declaration

Position the cursor on an identifier and do 'Find Declaration'. Then it will search the declaration of this identifier, open the file and jump to it.

Every find declaration sets a Jump Point. That means you jump with find declaration to the declaration and easily jump back with Search -> Jump back.

There are some differences to Delphi: The codetools work on sources following the normal pascal rules, instead of using the compiler output. The compiler returns the final type. The codetools see the sources and all steps in between. For example:

The Visible property is first defined in TControl (controls.pp), then redefined in TCustomForm and finally redefined in TForm. Invoking find declaration on Visible will you first bring to Visible in TForm. Then you can invoke Find Declaration again to jump to Visible in TCustomForm and again to jump to Visible in TControl.

Same is true for types like TColor. For the compiler it is simply a 'longint'. But in the sources it is defined as

TGraphicsColor = -$7FFFFFFF-1..$7FFFFFFF;
TColor = TGraphicsColor;

And the same for forward defined classes: For instance in TControl, there is a private variable

FHostDockSite: TWinControl;

Find declaration on TWinControl jumps to the forward definition

TWinControl = class;

And invoking it again jumps to the real implementation

TWinControl = class(TControl)

This way you can track down every identifier and find every overload.

Hints:

  • You can jump back with Ctrl+H.
  • You can view/navigate all visited locations via Menu: View -> "jump history"
  • With a 5 button Mouse you can use the 2 extra buttons to go forward/backward between the visited points
(you can remap the buttons using advanced mouse options)

Identifier Completion

"Identifier Completion" is invoked by Ctrl+space. It shows all identifiers in scope. For example:

 procedure TForm1.FormCreate(Sender: TObject);
 begin
   |
 end;

Place the cursor between begin and end and press Ctrl+space. The IDE/CodeTools will now parse all reachable code and present you a list of all found identifiers. The CodeTools cache the results, so invoking it a second time will be much faster.

Note for Delphians: Delphi calls it Code completion.

Some identifiers like 'Write', 'ReadLn', 'Low', 'SetLength', 'Self', 'Result', 'Copy' are built into the compiler and are not defined anywhere in source. The identifier completion has a lot of these things built in as well. If you find one missing, just create a feature request in the bug tracker.

Identifier completion does not complete all keywords. So you can not use it to complete 'repe' to 'repeat'. For these things use Ctrl+W Word Completion or Ctrl+J Code Templates. Since 0.9.27 identifier completion completes some keywords.

Identifier completion shows even those identifiers, that are not compatible.

Prefix

You can start identifier completion in a word. Then the letters to the left will be taken as prefix. For example:

 procedure TForm1.FormCreate(Sender: TObject);
 begin
   Ca|ption
 end;

The box will show you only the identifiers beginning with 'Ca'.

Keys

  • Letter or number: add the character to the source editor and the current prefix. This will update the list.
  • Backspace: remove the last character from source editor and prefix. Updates the list.
  • Return: replace the whole word at cursor with the selected identifier and close the popup window.
  • Shift+Return: as Return, but replaces only the prefix (left part) of the word at the cursor.
  • Up/Down: move selection
  • Escape: close popup without change
  • Tab: completes the prefix to next choice. For example: The current prefix is 'But' and the identifier completion only shows 'Button1' and 'Button1Click'. Then pressing Tab will complete the prefix to 'Button1'.
  • Else: as Return and add the character to the source editor

Methods

When cursor is in a class definition and you identifier complete a method defined in an ancestor class the parameters and the override keyword will be added automatically. For example:

<syntaxhighlight> TMainForm = class(TForm) protected

 mous|

end; </DELPHI>

Completing MouseDown gives:

<syntaxhighlight> TMainForm = class(TForm) protected

 procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X,
        Y: Integer); override;

end; </DELPHI>

Properties

<syntaxhighlight> property MyInt: integer read |; </DELPHI>

Identifier completion will show FMyInt and GetMyInt.

<syntaxhighlight> property MyInt: integer write |; </DELPHI>

Identifier completion will show FMyInt and SetMyInt.

Uses section / Unit names

In uses sections the identifier completion will show the filenames of all units in the search path. These will show all lowercase (e.g. avl_tree), because most units have lowercase filenames. On completion it will insert the nice case of the unit (e.g. AVL_Tree).

Statements

<DELPHI> procedure TMainForm.Button1Click(Sender: TObject); begin

 ModalRe|;

end; </DELPHI>

becomes:

<DELPHI> procedure TMainForm.Button1Click(Sender: TObject); begin

 ModalResult:=|;

end; </DELPHI>

Word Completion

"Word Completion" is invoked by Ctrl+W. It shows all words of all currently open editors and can therefore be used in non pascal sources, in comments and for keywords.

Otherwise it works the same as identifier completion.

Goto Include Directive

"Goto Include Directive" in the search menu of the IDE jumps to {$I filename} statement where the current include file is used.

Publish Project

Creates a copy of the whole project. If you want to send someone just the sources and compiler settings of your code, this function is your friend.

A normal project directory contains a lot of information. Most of it is not needed to be published: The .lpi file contains session information (like caret position and bookmarks of closed units) and the project directory contains a lot of .ppu, .o files and the executable. To create a lpi file with only the base information and only the sources, along with all sub directories use "Publish Project".

Note: Since version 0.9.13 there is a new Project Option that allows you to store session information in a seperate file from the normal .lpi file. This new file ends with the .lps extension and only contains session information, which will leave you .lpi file much cleaner.

In the dialog you can setup the exclude and include filter, and with the command after you can compress the output into one archive.