Difference between revisions of "Textadept"

From Wiki
Jump to navigation Jump to search
m
(Added a line of code for the new method of switching themes in TA10.)
(9 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
[https://foicica.com/textadept/ Textadept] is a programmable text editor for Linux, Mac OSX and Windows. It is fully extensible using [https://www.lua.org/ Lua].
 
[https://foicica.com/textadept/ Textadept] is a programmable text editor for Linux, Mac OSX and Windows. It is fully extensible using [https://www.lua.org/ Lua].
  
 +
= ConTeXt with Textadept (MS Windows) =
 +
(updated 2017/12)
  
= How to ConTeXt with Textadept (MS Windows) =
+
== Step 1: Install '''Textadept''' ==
(updated 2017/03)
 
  
== Step 1: Install / Update '''ConTeXt''' ==
+
1.1. [https://foicica.com/textadept/download/textadept_LATEST.win32.zip Download] and extract [https://foicica.com/textadept/ '''Textadept'''] to a folder of your choice.
  
Installation and update of ConTeXt works the same. If you only want to update ConTeXt you can start directly from point 3.
+
1.2. Use <code>textadept.exe</code> from the extracted folder to start Textadept.
  
1. [http://standalone.contextgarden.net/setup/ Download] ConTeXt.
+
== Step 2: Tweak '''Textadept''''s settings ==
* Windows x86 / 32 bit users: [http://standalone.contextgarden.net/setup/context-setup-mswin.zip context-setup-mswin.zip]
 
* Windows x64 / 64 bit users: [http://standalone.contextgarden.net/setup/context-setup-win64.zip context-setup-win64.zip]
 
** Download the x64 / 64 bit version only when you are really sure, that you '''need''' it.
 
  
2. Extract the archive to a location of your choice.
+
'''Note''' that almost all changes to Textadept are saved in the file <code>init.lua</code>. There is two of them, of which you should edit only one:
* You might want to change the name of the extracted directory to a shorter one as it will be the final location for ConTeXt.
 
  
 +
* One of them is in the extracted Textadept main folder. It is '''not recommended''' to edit this file as your changes will be lost when you update Textadept. Instead:
 +
* When you start Textadept for the first time, a new folder  <code>SYSDRIVE:\users\USERNAME\.textadept</code> gets created. It also contains a file called <code>init.lua</code>. This is the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty.
  
3. Install / Update ConTeXt
+
Usually you have to restart Textadept after changing its configuration files. Robert Gieseke created a code though, which you can add to your <code>init.lua</code> to circumvent having to restart Textadept whenever a change is made:
  
 +
  -- Save and reset Lua state: `F9`
 +
  keys['f9'] = function()    -- Mac OSX users might prefer:    keys[OSX and 'mf9' or 'f9']
 +
    io.save_file()
 +
    reset()
 +
  end
  
3. Method 1: Write a batch file
+
Save <code>init.lua</code> and restart Textadept once. After doing so you can add changes to Textadept's configuration files and press <code>F9</code>-key afterwards to save and load the changes without having to restart Textadept.
  
Since at this point the installation and update of ConTeXt work the same, the most effective solution is to create a batch file. To do so
+
=== Step 2.1: Bind a PDF build command into Textadept ===
  
* use Windows Explorer to navigate to your ConTeXt directory. In there should be a file called <code>first-setup.bat</code>.
+
2.1.1. Use Textadept to open your <code>init.lua</code> stored in <code>SYSDRIVE:\users\USER\.textadept\</code>.
* Use Windows Notepad or <code>Right-click</code> -> '''New''' -> '''Textfile''' to create such.
 
* If you only want ConTeXt mkiv (highly '''recommended'''), add the following line to the new and empty textfile:
 
  first-setup -engine=luatex -modules=all
 
* Save the file as a '''batch'''-file and name it something like <code>update.bat</code>.
 
** '''Note''' that the document ending has to be <code>.bat</code> not <code>.txt</code> or anything else. You might have to rename the file ending by hand.
 
* Execute the batch file you just created by double-clicking on it. A command prompt window should pop up.
 
** If it appears for only a few seconds, chances are high that the download server is down. In that case you might want to re-try the procedure at some other time.
 
* Wait for the download / update to finish. After it is done, the command window should disappear by itself.
 
** ConTeXt's folder's size should be around 380 - 400 MB when everything worked fine.
 
  
 
+
2.1.2. Add an execute command for ConTeXt to Textadept's menu:
3. Method 2: Type the command by hand
 
 
 
* Use Windows Explorer to navigate to your ConTeXt directory.
 
** Click into the upper white field where the current location is displayed.
 
** Enter <code>cmd</code> and press <code>Enter</code>-key.
 
** Now Windows command prompt should pop up with the correct location.
 
* Otherwise you can start your Windows command prompt like this:
 
** by using the key shortcut <code>Windows-key + R</code>, entering <code>cmd</code> and pressing <code>Enter</code>-key.
 
** Alternatively you can use <code>Start</code> -> <code>Programs</code> -> <code>Accessories</code> -> <code>Command Pompt</code>.
 
* Some DOS commands you might need:
 
** <code>dir</code> list the content of the current directory
 
** <code>cd DIRECTORY</code> change to directory with name DIRECTORY
 
** <code>cd..</code> change to superior directory
 
** <code>cd\</code> change to root drive
 
** <code>X:</code> change to drive X:
 
* In the end your command prompt should look like this:
 
  X:\ConTeXt>_
 
* If you only want ConTeXt mkiv (highly '''recommended'''), enter the following line and press <code>Enter</code>-key:
 
  first-setup -engine=luatex -modules=all
 
* Wait until the download / update is complete. Afterwards you can close the command prompt by entering <code>exit</code> and pressing <code>Enter</code>-key or by simply closing the window.
 
 
 
== Step 2: Add ConTeXt's executables folder to Windows search PATH ==
 
 
 
'''Note''': you will need admin rights for this. On public machines you most probably won't be able to add ConTeXt to that machine's path. In that case skip this step and go to Step 3 respectively Step 4.1 directly.
 
 
 
-- work in progress --
 
 
 
== Step 3: Install '''Textadept''' ==
 
 
 
1. [https://foicica.com/textadept/download/textadept_LATEST.win32.zip Download] and extract [https://foicica.com/textadept/ '''Textadept'''] to a folder of your choice.
 
 
 
2. Use <code>textadept.exe</code> from the extracted folder to start '''Textadept'''.
 
 
 
== Step 4: Tweak '''Textadept''''s settings ==
 
 
 
=== Step 4.1: Bind a PDF build command into Textadept ===
 
 
 
1. Use your freshly installed Textadept to open Textadept's main configuration file called <code>init.lua</code>.
 
* After extraction of the downloaded Textadept archive there is a file called <code>init.lua</code> in the main program folder. It is '''not recommended''' to edit this file as your changes will be lost when you update Textadept. Instead:
 
* When you start Textadept for the first time a new folder  <code>SYSDRIVE:\users\USERNAME\.textadept</code> gets created. It also contains the file called <code>init.lua</code>. It's the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty.
 
 
 
2. Add an execute command for ConTeXt to Textadept's menu:
 
* If your ConTeXt executables folder is already in the Windows search PATH:
 
 
   textadept.run.compile_commands.tex = 'mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
 
   textadept.run.compile_commands.tex = 'mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
* If for some reason you can't add the folder to PATH you have to add the full path to your ConTeXt executables. For example:
+
* '''Note''' that your ConTeXt executables folder has to be in the Windows search path!
  textadept.run.compile_commands.tex = 'C:/ctx/tex/texmf-mswin/bin/mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
 
* '''Note''' that you have to use slash <code>/</code> instead of backslash <code>\</code> in the file path, since Lua (same as ConTeXt) interprets a <code>\</code> as the beginning of a command, while for Windows it doesn't make any difference.
 
  
3. Restart Textadept to reload the modified <code>init.lua</code>.
+
2.1.3. Restart Textadept to reload the modified <code>init.lua</code>.
  
4. Open or create a ConTeXt test document:
+
2.1.4. Open or create a ConTeXt test document:
 
   \starttext
 
   \starttext
 
     hello world!
 
     hello world!
 
   \stoptext
 
   \stoptext
 +
* You will have to save the file with an appropriate ending first, after that it will be recognized as ConTeXt format file automatically.
  
5. Use Textadept's '''Tools''' -> '''Compile''' to build a PDF with the options added to <code>init.lua</code>. A message buffer with compilation status will open in a seperate tab.
+
2.1.5. Use Textadept's '''Tools''' -> '''Compile''' to build a PDF with the options added to <code>init.lua</code>. A message buffer with compilation status will open in a seperate tab.
  
6. When you have a popular PDF reader installed already, it should pop up at the end of the process and show the created PDF output. [https://www.sumatrapdfreader.org/free-pdf-reader.html '''Sumatra PDF'''] is highly recommended for this.
+
2.1.6. When you have a popular PDF reader installed already, it should pop up at the end of the process and show the created PDF output. [https://www.sumatrapdfreader.org/free-pdf-reader.html '''Sumatra PDF'''] is highly recommended for this.
  
=== Step 4.2: Lexing (command highlighting & code folding) ===
+
=== Step 2.2: Lexing (command highlighting & code folding) ===
  
A lexer is a file that defines command highlighting and code folding keywords. Since Textadept comes with an own ConTeXt lexer, it is a good idea to bind <code>*.tex</code> files to Textadept's ConTeXt lexer, as otherwise you won't benefit from the mentioned features when writing ConTeXt documents. So
+
A lexer is a file that defines command highlighting and code folding keywords. Textadept comes with a ConTeXt lexer. In order to be able to use command highlighting and code folding when writing ConTeXt documents, you have to bind those documents to the lexer. To do so
  
1. add the following line to your <code>USER/.textadept/init.lua</code> and save it afterwards:
+
2.2.1. add the following line to your <code>USER/.textadept/init.lua</code> and save it afterwards:
 
   textadept.file_types.extensions.tex = 'context'
 
   textadept.file_types.extensions.tex = 'context'
* If you plan to use LaTeX and ConTeXt, you should use different file extensions. For example <code>*.tex</code> for LaTeX and <code>*.cxd</code> for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since <code>.tex</code> files are automatically recognized as LaTeX documents:
+
* If you plan to use LaTeX and ConTeXt, you might want to use different file extensions for each format. For example <code>*.tex</code> for LaTeX and <code>*.cxd</code> for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since <code>.tex</code> files are automatically recognized as LaTeX documents:
 
   textadept.file_types.extensions.cxd = 'context'
 
   textadept.file_types.extensions.cxd = 'context'
 +
** When linking files within ConTeXt documents without adding an extension though, ConTeXt will expect those files to have the ending <code>*.tex</code>, i.e. you will have to work with filenames and extensions when using a format other than <code>*.tex</code>, which on the other hand should not be seen as a disadvantage.
  
2. Restart Textadept to reload <code>init.lua</code>.
+
2.2.2. Restart Textadept to reload <code>init.lua</code>.
  
3. Open a ConTeXt document and check Textadept's status bar in the lower right corner. It should say '''context'''. If it says '''latex''' make sure it really is a ConTeXt file or repeat the procedure.
+
2.2.3. Open a ConTeXt document and check Textadept's status bar in the lower right corner. It should say '''context'''. If it says '''latex''' make sure it really is a ConTeXt file or repeat the procedure.
  
 
== Optional: Additional '''Textadept''' tweaks ==
 
== Optional: Additional '''Textadept''' tweaks ==
Line 117: Line 69:
 
=== Themes & editor font changes ===
 
=== Themes & editor font changes ===
 
You can change the theme, font and font size of Textadept with the following line
 
You can change the theme, font and font size of Textadept with the following line
   ui.set_theme('dark', {font = 'Monospace', fontsize = 10})
+
   ui.set_theme('dark', {font = 'Monospace', fontsize = 10})       -- Textadept v9
in which the expression '''dark''' is the filename of the theme located either in <code>Textadept\themes</code> or you can download and add new themes to <code>USER\.textadept\themes</code>
+
  buffer:set_theme('dark', {font = 'Monospace', fontsize = 10})  -- Textadept v10
(create the folder if it's not there yet).
+
in which the expression '''dark''' is the filename of the theme located in either <code>Textadept\themes</code> or <code>USER\.textadept\themes</code>
There are more settings which you can look up in Textadept's [https://foicica.com/textadept/manual.html#Themes online manual].
+
(after you created or downloaded and added them; create the folder as it usually won't be there yet).
 +
 
 +
* Many ''base16'' themes for Textadept can be found at [https://github.com/rgieseke/textadept-themes Robert Gieseke's GitHub]. You can preview them [https://termux.com/add-on-styling-color-preview.html here] (partially).
 +
 
 +
* There are more settings which you can look up in Textadept's [https://foicica.com/textadept/manual.html#Themes manual].
  
 
=== Snippets ===
 
=== Snippets ===
Snippets are predefined code blocks. You add them to your <code>USER/.textadept/init.lua</code>. Snippets in Textadept look like this:
+
Snippets are predefined code or text blocks. Using snippets can save a lot of time as you won't have to retype often used commands and text passages. You add snippets to your <code>USER/.textadept/init.lua</code>. In Textadept snippets look like this:
 +
  snippets.context['TRIGGERKEYWORD'] = 'PASTEDTEXT'
 +
 
 +
To get an idea how writing snippets (for ConTeXt) works, you can copy and paste the following list to your <code>init.lua</code>:
  
 
   -- The first line is mandatory:
 
   -- The first line is mandatory:
 
   snippets['context'] = snippets['context'] or {}
 
   snippets['context'] = snippets['context'] or {}
 
   -- Snippets start here:
 
   -- Snippets start here:
   snippets.context['emph']        = '{\\em %0}'
+
   snippets.context['emph']        = '{\\em %<selected_text>%0}' -- emphasized text/math
   snippets.context['bold']        = '{\\bf %0}'
+
  snippets.context['ital']        = '{\\it %<selected_text>%0}' -- italic text/math
   snippets.context['start']      = '\\start%1\n%0\n\\stop%1'
+
   snippets.context['bold']        = '{\\bf %<selected_text>%0}' -- bold text/math
   snippets.context['itemize']    = '\\startitemize\n\t%0\n\\stopitemize'
+
  snippets.context['boldit']      = '{\\bi %<selected_text>%0}' -- bold italic text/math
   snippets.context['item'] = '\\startitem\n\t%0\n\\stopitem'
+
   snippets.context['start']      = '\\start%1\n\t%0\n\\stop%1'
 +
   snippets.context['itemize']    = '\\startitemize[packed]\n\t\\startitem\n\t\t%<selected_text>%0\n\t\\stopitem\n\\stopitemize' -- start itemization
 +
   snippets.context['item'] = '\\startitem\n\t%<selected_text>%0\n\\stopitem'
 
   snippets.context['enumerate']  = '\\startenumerate\n\t%0\n\\stopenumerate'
 
   snippets.context['enumerate']  = '\\startenumerate\n\t%0\n\\stopenumerate'
   snippets.context['chapter']    = '\\startchapter[title={%1},marking{%1}]\n%0\n\\stopchapter'
+
   snippets.context['chapter']    = '\\startchapter[title={%1},marking{%1}]\n\t%0\n\\stopchapter'
   snippets.context['section']    = '\\startsection[title={%1},marking{%1}]\n%0\n\\stopsection'
+
   snippets.context['section']    = '\\startsection[title={%1},marking{%1}]\n\t%0\n\\stopsection'
   snippets.context['ssection']    = '\\startsubsection[title={%1},marking{%1}]\n%0\n\\stopsubsection'
+
   snippets.context['ssection']    = '\\startsubsection[title={%1},marking{%1}]\n\t%0\n\\stopsubsection'
   snippets.context['title']      = '\\starttitle[title={%1},marking{%1}]\n%0\n\\stoptitle'
+
   snippets.context['title']      = '\\starttitle[title={%1},marking{%1}]\n\t%0\n\\stoptitle'
   snippets.context['subject']    = '\\startsubject[title={%1},marking{%1}]\n%0\n\\stopsubject'
+
   snippets.context['subject']    = '\\startsubject[title={%1},marking{%1}]\n\t%0\n\\stopsubject'
   snippets.context['ssubject']    = '\\startsubsubject[title={%1},marking{%1}]\n%0\n\\stopsubsubject'
+
   snippets.context['ssubject']    = '\\startsubsubject[title={%1},marking{%1}]\n\t%0\n\\stopsubsubject'
  
* '''Note''' that a backslash <code>\</code> is created by typing a double backslash <code>\\</code>.
+
* '''Note''' that a backslash <code>\</code> is set by typing a double backslash <code>\\</code>.
  
 
* The most important formatting commands are the following:
 
* The most important formatting commands are the following:
**<code>%0</code> creates a primary input caret (the cursor will jump here first)
+
**<code>\n</code> set a line break (new line)
**<code>%1</code> creates one or multiple secondary input carets
+
**<code>\t</code> set a tabulated
**<code>%n</code> creates a new line
+
**<code>%0</code> set the ''closing'' caret (placeholder) (the cursor will jump here '''last''')
**<code>%t</code> creates a tab
+
**<code>%1</code> set one or multiple input carets (<code>%1</code>, <code>%2</code>, <code>%3</code> and so on; you can also use the same integer multiple times: e.g. <code>\\start%1 ... \\stop%1</code>)
 +
**<code>%<selected_text></code> this is where highlighted text will be pasted when enclosing it with a snippet (e.g. <code>{\\bi %<selected_text>%0}</code>)
  
* After adding snippets, you have to restart Textadept first.
+
* After adding snippets, you have to restart Textadept or reset Lua state as described in Step 2.
  
* Then you can use <code>Ctrl + K</code> (by default on Windows machines) to choose from the list of snippets, when a ConTeXt document is opened in the active tab.
+
* You can paste snippets into ConTeXt documents
 +
** either by typing the keyword that you defined within <code>snippets.context['KEYWORD']</code> and pressing <code>Tab</code>-key afterwards
 +
** or by using <code>Ctrl + K</code> (by default on Windows machines) to choose from the list of snippets. No matter in which order you add them to your <code>init.lua</code>, they will show up sorted alphabetically.
 +
* '''Note''' that since this way you bound snippets to Textadept's ConTeXt lexer, Textadept's status bar in the lower right corner has to say '''context''', otherwise use a ConTeXt document or see Step 2.2.
  
 +
* Read more about snippets in Textadept's [https://foicica.com/textadept/api.html#textadept.snippets manual].
  
 
=3rd party projects=
 
=3rd party projects=
  
A ConTeXt module for textadept is being developed at [https://github.com/stephengaito/ta-context-latex ta-context-latex].
+
A ConTeXt module for Textadept is being developed at [https://github.com/stephengaito/ta-context-latex ta-context-latex].
  
Note though, that if you plan to use Textadept without LaTeX with ConTeXt mkiv only (recommended), then you might not need the package mentioned above as it comes with literally only a hand full of ConTeXt snippets. It's almost more comfortable to create own ConTeXt snippets with the ease of Textadept (see above).
+
Note though, that if you plan to use Textadept without LaTeX with ConTeXt mkiv only (recommended), then you might not need the package mentioned above as it comes with literally only a hand full of ConTeXt snippets. It also needs additional software to be installed (Textredux, ctags), so that it's almost more comfortable to create own ConTeXt snippets with the ease of Textadept (see above).

Revision as of 08:00, 10 August 2018

< Text Editors

Introduction

Textadept is a programmable text editor for Linux, Mac OSX and Windows. It is fully extensible using Lua.

ConTeXt with Textadept (MS Windows)

(updated 2017/12)

Step 1: Install Textadept

1.1. Download and extract Textadept to a folder of your choice.

1.2. Use textadept.exe from the extracted folder to start Textadept.

Step 2: Tweak Textadept's settings

Note that almost all changes to Textadept are saved in the file init.lua. There is two of them, of which you should edit only one:

  • One of them is in the extracted Textadept main folder. It is not recommended to edit this file as your changes will be lost when you update Textadept. Instead:
  • When you start Textadept for the first time, a new folder SYSDRIVE:\users\USERNAME\.textadept gets created. It also contains a file called init.lua. This is the file and location where you should save all your Textadept settings. This way you can make a copy and use it on several computers. When you open it for the first time it should be empty.

Usually you have to restart Textadept after changing its configuration files. Robert Gieseke created a code though, which you can add to your init.lua to circumvent having to restart Textadept whenever a change is made:

 -- Save and reset Lua state: F9
 keys['f9'] = function()    -- Mac OSX users might prefer:    keys[OSX and 'mf9' or 'f9']
   io.save_file()
   reset()
 end

Save init.lua and restart Textadept once. After doing so you can add changes to Textadept's configuration files and press F9-key afterwards to save and load the changes without having to restart Textadept.

Step 2.1: Bind a PDF build command into Textadept

2.1.1. Use Textadept to open your init.lua stored in SYSDRIVE:\users\USER\.textadept\.

2.1.2. Add an execute command for ConTeXt to Textadept's menu:

 textadept.run.compile_commands.tex = 'mtxrun --autogenerate --script context --autopdf --purge --synctex=-1 "%f"'
  • Note that your ConTeXt executables folder has to be in the Windows search path!

2.1.3. Restart Textadept to reload the modified init.lua.

2.1.4. Open or create a ConTeXt test document:

 \starttext
   hello world!
 \stoptext
  • You will have to save the file with an appropriate ending first, after that it will be recognized as ConTeXt format file automatically.

2.1.5. Use Textadept's Tools -> Compile to build a PDF with the options added to init.lua. A message buffer with compilation status will open in a seperate tab.

2.1.6. When you have a popular PDF reader installed already, it should pop up at the end of the process and show the created PDF output. Sumatra PDF is highly recommended for this.

Step 2.2: Lexing (command highlighting & code folding)

A lexer is a file that defines command highlighting and code folding keywords. Textadept comes with a ConTeXt lexer. In order to be able to use command highlighting and code folding when writing ConTeXt documents, you have to bind those documents to the lexer. To do so

2.2.1. add the following line to your USER/.textadept/init.lua and save it afterwards:

 textadept.file_types.extensions.tex = 'context'
  • If you plan to use LaTeX and ConTeXt, you might want to use different file extensions for each format. For example *.tex for LaTeX and *.cxd for ConTeXt documents. In that case you only have to bind your new ConTeXt extension to Textadept's ConTeXt lexer, since .tex files are automatically recognized as LaTeX documents:
 textadept.file_types.extensions.cxd = 'context'
    • When linking files within ConTeXt documents without adding an extension though, ConTeXt will expect those files to have the ending *.tex, i.e. you will have to work with filenames and extensions when using a format other than *.tex, which on the other hand should not be seen as a disadvantage.

2.2.2. Restart Textadept to reload init.lua.

2.2.3. Open a ConTeXt document and check Textadept's status bar in the lower right corner. It should say context. If it says latex make sure it really is a ConTeXt file or repeat the procedure.

Optional: Additional Textadept tweaks

Themes & editor font changes

You can change the theme, font and font size of Textadept with the following line

 ui.set_theme('dark', {font = 'Monospace', fontsize = 10})       -- Textadept v9
 buffer:set_theme('dark', {font = 'Monospace', fontsize = 10})   -- Textadept v10

in which the expression dark is the filename of the theme located in either Textadept\themes or USER\.textadept\themes (after you created or downloaded and added them; create the folder as it usually won't be there yet).

  • There are more settings which you can look up in Textadept's manual.

Snippets

Snippets are predefined code or text blocks. Using snippets can save a lot of time as you won't have to retype often used commands and text passages. You add snippets to your USER/.textadept/init.lua. In Textadept snippets look like this:

 snippets.context['TRIGGERKEYWORD'] = 'PASTEDTEXT'

To get an idea how writing snippets (for ConTeXt) works, you can copy and paste the following list to your init.lua:

 -- The first line is mandatory:
 snippets['context'] = snippets['context'] or {}
 -- Snippets start here:
 snippets.context['emph']        = '{\\em %<selected_text>%0}' -- emphasized text/math
 snippets.context['ital']        = '{\\it %<selected_text>%0}' -- italic text/math
 snippets.context['bold']        = '{\\bf %<selected_text>%0}' -- bold text/math
 snippets.context['boldit']      = '{\\bi %<selected_text>%0}' -- bold italic text/math
 snippets.context['start']       = '\\start%1\n\t%0\n\\stop%1'
 snippets.context['itemize']     = '\\startitemize[packed]\n\t\\startitem\n\t\t%<selected_text>%0\n\t\\stopitem\n\\stopitemize' -- start itemization
 snippets.context['item'] 	 = '\\startitem\n\t%<selected_text>%0\n\\stopitem'
 snippets.context['enumerate']   = '\\startenumerate\n\t%0\n\\stopenumerate'
 snippets.context['chapter']     = '\\startchapter[title={%1},marking{%1}]\n\t%0\n\\stopchapter'
 snippets.context['section']     = '\\startsection[title={%1},marking{%1}]\n\t%0\n\\stopsection'
 snippets.context['ssection']    = '\\startsubsection[title={%1},marking{%1}]\n\t%0\n\\stopsubsection'
 snippets.context['title']       = '\\starttitle[title={%1},marking{%1}]\n\t%0\n\\stoptitle'
 snippets.context['subject']     = '\\startsubject[title={%1},marking{%1}]\n\t%0\n\\stopsubject'
 snippets.context['ssubject']    = '\\startsubsubject[title={%1},marking{%1}]\n\t%0\n\\stopsubsubject'
  • Note that a backslash \ is set by typing a double backslash \\.
  • The most important formatting commands are the following:
    • \n set a line break (new line)
    • \t set a tabulated
    • %0 set the closing caret (placeholder) (the cursor will jump here last)
    • %1 set one or multiple input carets (%1, %2, %3 and so on; you can also use the same integer multiple times: e.g. \\start%1 ... \\stop%1)
    • %<selected_text> this is where highlighted text will be pasted when enclosing it with a snippet (e.g. {\\bi %<selected_text>%0})
  • After adding snippets, you have to restart Textadept or reset Lua state as described in Step 2.
  • You can paste snippets into ConTeXt documents
    • either by typing the keyword that you defined within snippets.context['KEYWORD'] and pressing Tab-key afterwards
    • or by using Ctrl + K (by default on Windows machines) to choose from the list of snippets. No matter in which order you add them to your init.lua, they will show up sorted alphabetically.
  • Note that since this way you bound snippets to Textadept's ConTeXt lexer, Textadept's status bar in the lower right corner has to say context, otherwise use a ConTeXt document or see Step 2.2.
  • Read more about snippets in Textadept's manual.

3rd party projects

A ConTeXt module for Textadept is being developed at ta-context-latex.

Note though, that if you plan to use Textadept without LaTeX with ConTeXt mkiv only (recommended), then you might not need the package mentioned above as it comes with literally only a hand full of ConTeXt snippets. It also needs additional software to be installed (Textredux, ctags), so that it's almost more comfortable to create own ConTeXt snippets with the ease of Textadept (see above).