TeXstudio allows you to insert your own macros. These macros are defined with the "Macros - Edit Macros" menu.Macros can consist of simple text which is directly placed into txs. It can also be an "environment" which are automatically extended by begin/end or it can be a java script.The needed functionality can be selected by checkbox.The "abbreviation" is a pseudo-command for the latex completer. If the pseudo-command is completed, the macro will be inserted instead. Note that the pseudo-command needs to start with a backslash ("\")."Trigger" is a regular expression which triggers the inclusion of the macro: When the last written characters match this expression, they are removed and the macro is inserted/executed. (see below for more details).Some macros can be directly downloaded from an internet repository. The dialog is started with the button "Browse". For easier data exchange, macros can be im- and exported to a file. If you want to add a macro of your own to that repository, you can hand it in as a feature request on Github. Each macro can be assigned a fixed shortcut in the "Shortcut" box.The list of macros on the left-hand side represents the macro ordering in the macro-menu. It is rearranged with the "up"/"down"/"add"/"remove" buttons or with drag and drop. Folders can be added to sort a larger number of macros sensibly. To move macros into/from folders, only drag and drop works.The "run script" button directly executes a script in the editor for testing.
Apart from normal text, some special codes are recognized and replaced on insertion.If you write % somewhere the cursor will be placed at that place in the inserted text. (A second % will select everything between them).
Write % to mark it as placeholder which is highlighted in the text and can be selected by Ctrl+Left/Right. Additional properties of the placeholder can be set after a %:, e.g. %. The available properties are:select: The placeholder will be selected (similar to %)
multiline: The placeholder is used for multiline text. If a macro insertion replaces an existing text, the replaced text is again inserted into a placeholder in the macro. If the original text spans more than one line, it will be inserted into a placeholder with the multiline property. Otherwise in a placeholder with the select-property.
persistent: The placeholder is not automatically removed, when its text is changed in the editor
mirror: The placeholder is a mirror of another placeholder in the macro and thus will always have the same content as the original placeholder. You should set an id, so it knows which placeholders are connected
id:123: The id of the placeholder
columnShift:-12: The placeholder is not placed where the %The option %(filefilter%) will be replaced by a filename which is asked for in a file dialog. The file filter is the standard Qt-Filefilterformat.For example "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)", see also Qt-Doc
F1 F9 Macro Redone Final.exe
More examples can be found in the Wiki.4.6.4 Triggers4.6.4.1 Regular ExpressionsIn its simplest form, the trigger is simply a text, which is replaced by the macro.E.g. trigger="eg" macro="example given", "eg" in "the leg" is replaced on pressing "g" by "example given"As the trigger is a regular expression, more elaborate triggers can be created. TXS makes use of look-behind searching: "(?
Additionally the following special trigger terms (without parentheses) can be used to execute the script when the corresponding event occurs:Special TriggerExecuted on Event?txs-startTeXstudio is started.?new-fileA new file is created?new-from-templateA new file is created from a template?load-fileA file is loaded?load-this-fileThe file containing the macro is loaded (only makes sense, if the script is defined as magic comment)?save-fileA file is saved?close-fileA file is closed?master-changedA document is un/defined as master document?after-typesetA latex-like command has ended?after-command-runA command run has ended (e.g. a compile command that calls latex twice and opens the viewer, will trigger this event once, but after-typeset twice)Multiple of these special triggers can be combined by symbols.
This defines a temporary script macro which is executed, when the file is loaded, and which in turns loads the two files in /tmp/test. .The macros defined via TXS-SCRIPT are active in all files of a document (e.g. included files). You cannot run them manually. They are run viathe trigger (regular expression or special trigger, see section on triggers). The macro is just read once, when the file is opened.Changes during an edit session will only take effect when you reopen the file.% !BIB program = biberThe special % !BIB program command is understood for compatibility with TeXShop and TeXWorks (also in the variant % !BIB TS-program). This is equivalent to % !TeX TXS-program:bibliography = txs:///biber
texstudio file [--config DIR] [--root] [--line xx[:cc]] [--insert-cite citation] [--start-always] [--pdf-viewer-only] [--page yy] [--no-session]--config DIRuse the specified settings directory.--ini-file FILEdeprecated:use --config instead.--rootdefines the document as explicit root document (formerly called master document).--masterdeprecated:use --root instead.--line xx[:cc]position the cursor at line LINE and column COL, e.g. "--line 2:5" will jump to column 5 in line 2.--insert-cite citationpushes a bibtex key to TeXstudio, that will be inserted at the cursor position. This is intended as an interface for external bibliography managers to push citations to TeXstudio. You may either pass an (also custom) command like \mycitekey or just the key. In the latter case, it is expanded to \citekey. Also comma separated keylists are supported. TeXstudio recognizes, if the cursor is already within a citation macro. If so, only the key is inserted at an appropriate position, otherwise the full citation command is inserted.--start-alwaysstart a new instance, even if TXS is already running. This allows using of multiple instances.--pdf-viewer-onlyrun as a standalone pdf viewer without an editor--pagedisplay a certain page in the pdf viewer--no-sessiondo not load/save the session at startup/close
2ff7e9595c
Comments