SciTE has a powerful feature for inserting abbreviations (also known as snippets) using keyboard shortcuts. Here's how it works and how to set it up:
1. Abbreviations File:
SciTE uses a file called abbreviations.txt to store the abbreviations and their expansions. This file is typically located in:
- User-specific:
%APPDATA%\SciTE\abbreviations.txt (This is the recommended location for customizations)
- Installation directory:
C:\Program Files (x86)\SciTE\abbreviations.txt (or similar, depending on your SciTE installation)
2. Format of abbreviations.txt:
Each line in abbreviations.txt defines an abbreviation. The format is:
abbreviation expansion
- abbreviation: The short text you'll type to trigger the expansion.
- expansion: The full text that will replace the abbreviation.
Example:
sig Sincerely,\nYour Name
date $(date) // Inserts the current date (SciTE variable)
fori for i in range(10): // Python loop snippet
3. Setting up Abbreviations:
- Open
abbreviations.txt: Open the file in a text editor (SciTE is fine).
- Add your abbreviations: Add lines in the format described above.
- Save the file.
4. Using Abbreviations in SciTE:
- Type the abbreviation: In your SciTE editor, type the abbreviation you defined (e.g.,
sig).
- Press
Tab: Immediately after typing the abbreviation, press the Tab key. SciTE will automatically replace the abbreviation with its expansion.
5. Customizing the Trigger Key (Optional):
By default, Tab is used to trigger the abbreviation expansion. You can change this to a different key if you prefer.
-
Open SciTEGlobal.properties: Locate and open the SciTEGlobal.properties file.
-
Modify abbreviation.key: Find the line that starts with abbreviation.key. Change the key to your desired shortcut. For example:
abbreviation.key=Ctrl-Space
This would change the trigger key to Ctrl+Space.
-
Save the file and restart SciTE.
Example abbreviations.txt for AutoIt:
msgbox MsgBox(0, "Title", "Message")
sleep Sleep(1000)
fileopen FileOpen("C:\path\to\file.txt", 0)
Important Notes:
- Case Sensitivity: Abbreviations are case-sensitive by default.
- SciTE Variables: You can use SciTE variables in your expansions (e.g.,
$(date), $(time), $(filename)).
- Conflicts: If you have multiple abbreviations that start with the same characters, SciTE will expand the first one it finds in the
abbreviations.txt file.
- Restart SciTE: Always restart SciTE after modifying
abbreviations.txt or SciTEGlobal.properties for the changes to take effect.
By using abbreviations, you can significantly speed up your coding process in SciTE by automatically inserting frequently used code snippets with a simple keyboard shortcut.