# ted A text editor. To download installers for ted for Windows and Debian/Ubuntu, go to the [releases](https://github.com/pommicket/ted/releases). To get autocomplete and go-to-definiton you will need [ctags](https://github.com/universal-ctags/ctags). You can install ctags on Debian/Ubuntu with: ```bash sudo apt install universal-ctags ``` ## Why? There are a lot of text editors out there. ted doesn't do anything new. Here are some benefits of ted: - Starts up immediately. - Doesn't lag for reasonably-sized files. - VERY small - a full ted installation is < 5 MB. ted isn't incredibly complicated, but it does have some nice features you might not find in other editors. ## Supported features - Customization of (pretty much) all colors and keyboard commands. - Basic text editing like copy+paste, undo+redo, etc. - Multiple tabs, each with a different file - Split screen - Auto-indent - Syntax highlighting for C, C++, Go, HTML, Java, JavaScript, LaTeX, Markdown, Python, Rust, and TypeScript. - Find and replace (with regular expressions!) - Run build command, go to errors - Run any shell command - Autocomplete - Go to definition - Go to line number - Indent/dedent selection, comment/uncomment selection ## Getting started with ted After installing ted, you can just start using it like you would any other editor. The keyboard shortcuts are mostly what you'd expect them to be (Ctrl+o for open, Ctrl+n for new, Ctrl+s for save, etc.). ### Tips - Even if you don't want to change anything with ted, it's a good idea to look at the config file (see below) to check out all of the keyboard shortcuts! - You can use Ctrl+f for "find", but if you want to search for something across multiple files, you can do Ctrl+! (run shell command), then run `grep -n search_term *.py`, for example (on Windows, you will need to have cygwin or something in your PATH for this to work). The `-n` ensures that ted can jump to the results, just like jumping to build errors. - ted uses PCRE for regular expressions. This means that when using find+replace, if you want to replace with a captured group, you need to use `$1`, not (as you might expect) `\1`. ### Configuration At any time, you can check out all the keyboard shortcuts, and add your own, by opening your ted.cfg file. To do this, press Ctrl+Shift+p to open the command palette, and select "open-config". There are several sections to this config file: - `[core]` for core settings - `[keyboard]` for keyboard shortcuts - `[colors]` for colors - `[extensions]` for which file extensions should be mapped to which programming languages Comments begin with `#`, and all other lines are of the form `key = value`. Strings can span multiple lines and can either be delimited with `"` or `\``. By default ted's settings will automatically update when you save the config file. The `core` section's settings should be pretty familiar (font size, etc.) or should have comments on the previous line explaining what they do. Keyboard shortcuts are of the form `key combo = action`, where `action` is an argument (number or string), followed by a command. The commands match the things in the command palette (Ctrl+Shift+p), but `:` is added to the beginning to make it clear it's a command. A list of key names can be found [here](https://wiki.libsdl.org/SDL2/SDL_Keycode). Colors are formatted like `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, where r, g, b, and a are red, green, blue, and alpha (transparency/opacity). You can use a [color picker](https://www.google.com/search?q=color+picker) to help you out. The extensions section is fairly self-explanatory. You can set settings for specific programming languages like this: ``` [HTML.core] # set tab width for HTML files to 2 tab-width = 2 ``` To reset your ted configuration to the default settings, delete your ted.cfg file (`~/.local/share/ted/ted.cfg` on Linux, `C:\Users\\AppData\Local\ted\ted.cfg` on Windows) or move it somewhere else. To change the font, create files called `font.ttf` and `font-bold.ttf` in the same directory as `ted.cfg`. At the moment, only monospace fonts are supported. ### IDE-like features If you are working in a compiled language, like C, you can press F4 to compile your code. The default is to run `make` in the current directory or one of its parents, depending on where `Makefile` is. On Windows, if `make.bat` exists, it will be run. If a `Cargo.toml` file exists in this directory or one of its parents, F4 will run `cargo build`. You can set the default build command in the `[core]` section of the config file. You can press Ctrl+\[ and Ctrl+\] to navigate between build errors. ### ctags vs LSP `ted` has support for two separate systems for IDE features. `ctags` is very lightweight (a ctags installation is just 1.6 MB), and allows for go-to-definition and limited autocompletion. This has very low CPU usage, and will work just fine on very large projects (for large projects I would recommend increasing `tags-max-depth` and turning `regenerate-tags-if-not-found` off). LSP servers have lots of features but use lots of CPU and memory, and may take longer to come up with completions/find definitions, especially for large projects. However the LSP server runs in a separate thread, so it will not slow down the ordinary text editing features of `ted` (unless the server starts using 100% of all CPU cores, which is unlikely). I would recommend trying out an LSP server if you're unsure about which one to use. ## LSP support ted has support for [LSPs](https://microsoft.github.io/language-server-protocol/)! You can Ctrl+Click on an identifier to go to its definition, or Ctrl+Shift+Click to go to its declaration, or Ctrl+Alt+Click to go to its type's definition. (clangd seems to sometimes go to the declaration even when the definition should be available, e.g. when Ctrl+clicking on the function declarations in `ted.h`. This is Not My Fault, and VSCode's clangd extension suffers from the same problem.) You can also press Ctrl+D to get a searchable list of all functions/types where you can select one to go to its definition. Press Ctrl+space to autocomplete. If there is only one possible completion from the tags file, it will be selected automatically. Otherwise, you'll get a popup showing all possible completions. You can press tab to select a completion (or click on it), and press Ctrl+space/Ctrl+shift+space to cycle between suggestions. Hover over an identifier and press F1 to see its type and documentation ("hover information"). While your cursor is over an identifier, you can press F2 to highlight where it is used ("document highlights"). If you turn on `highlight-auto` in the settings, the highlights will appear even if you don't press F2. Press Ctrl+U to see usages of the identifier under the cursor. You can use Ctrl+\[ and Ctrl+\] to navigate between them, just like build errors. If these features aren't working properly and you don't know why, try running ted in a terminal (non-Windows) or a debugger (Windows) so you can see the stderr output from the server. If an LSP server crashes or is having difficulty, you can run the `lsp-reset` command (via the command palette) to reset all running LSP servers. You can integrate any LSP server with ted by setting the `lsp` option in the `[core.]` section of `ted.cfg` to the command which starts the server. Some defaults will already be there, and are listed below. Make sure you install the LSP(s) you want and put the executables in your PATH (or change the `lsp` variable to include the absolute path if not). You can also set configuration options with the `lsp-configuration` option. Make sure the configuration you provide is valid JSON. ### C/C++ [clangd](https://clangd.llvm.org/installation) is enabled by default. On Debian/Ubuntu you can install it with: ```bash sudo apt install clangd-15 # replace 15 with the highest number you can get sudo ln -s /usr/bin/clangd-15 /usr/bin/clangd ``` ### Go The Go team's `go-pls` is enabled by default. You can download it [here](https://github.com/golang/tools/tree/master/gopls). ## Java Eclipse's `jdtls` is enabled by default. You can download it [here](download.eclipse.org/jdtls/milestones/?d). ## JavaScript/TypeScript `typescript-language-server` is enabled by default. You can download it by following [the instructions here](https://github.com/typescript-language-server/typescript-language-server). ## LaTeX `texlab` is enabled by default. You can download it [here](https://github.com/latex-lsp/texlab). ### Python `python-lsp-server` is enabled by default. You can download it [here](https://github.com/python-lsp/python-lsp-server). ### Rust `rust-analyzer` is enabled by default. You can download it by following [the instructions here](https://rust-analyzer.github.io/manual.html#rust-analyzer-language-server-binary). On Linux you can install it with: ```bash mkdir -p ~/.local/bin curl -L https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer chmod +x ~/.local/bin/rust-analyzer ``` ## Tags (lightweight LSP alternative) If an LSP is too much for you, you can also use [ctags](https://github.com/universal-ctags/ctags) for autocompletion and jump to definition. You can press Ctrl+T at any time to generate or re-generate tags. Ctrl+Click (go to definition), Ctrl+D (see all definitions), and autocomplete are all supported. Autocomplete will just complete to stuff in the tags file, so it won't complete local variable names for example. ## Building from source First, you will need PCRE2: https://github.com/PhilipHazel/pcre2/releases. Unzip it, put pcre2-10.X in the same folder as ted, and rename it to pcre2. To install `ted` from source on Linux, you will also need: - A C compiler - The SDL2 development libraries - cmake (for PCRE2) - imagemagick convert (for creating the .deb installer) These can be installed on Ubuntu/Debian with: ```bash sudo apt install clang libsdl2-dev cmake imagemagick ``` Then run `make -j4 release` to build or `sudo make install -j4` to build and install. You can also run `make ted.deb` to build the .deb installer. On Windows (64-bit), you will need to install Microsoft Visual Studio, then find and add vcvarsall.bat to your PATH. Next you will need the SDL2 VC development libraries: https://www.libsdl.org/download-2.0.php Extract the zip, copy SDL2-2.x.y into the ted directory, and rename it to SDL2. Also copy SDL2\\lib\\x64\\SDL2.dll to the ted directory. Then run `make.bat release`. To build the .msi file, you will need Visual Studio 2022, as well as the [Visual Studio Installer Projects extension](https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2022InstallerProjects). Then, open windows\_installer\\ted\\ted.sln, and build. ## Version history
Version Description Date
0.0 Very basic editor 2021 Jan 31
0.1 Syntax highlighting 2021 Feb 3
0.2 Line numbers, check if file changed by another program 2021 Feb 5
0.3 Find+replace, highlight matching parentheses, indent/dedent selection 2021 Feb 11
0.3a Find+replace bug fixes, view-only mode 2021 Feb 14
0.4 :build 2021 Feb 18
0.5 Go to definition 2021 Feb 22
0.5a Several bugfixes, go to line 2021 Feb 23
0.6 Split-screen 2021 Feb 28
0.7 Restore session, command selector, :shell, big bug fixes 2021 Mar 3
0.8 Autocomplete 2021 Mar 4
1.0 Bugfixes, small additional features, installers 2021 Apr 20
1.0r1 Windows-specific bugfixes, update to new version of PCRE2 2022 Jan 1
1.0r2 Various bugfixes involving closing tabs and windows 2022 Mar 26
1.0r3 Better TeX syntax highlighting, move to cursor on backspace/delete 2022 Jul 7
1.1 Minor fixes, syntax highlighting for JavaScript, Java, and Go 2022 Jul 22
1.2 Bug fixes, per-language settings 2022 Jul 29
1.2r1 Mouse X1/X2 bug fix, support for X1/X2 commands. 2022 Aug 19
1.2r2 Shift+PgUp/PgDown, many rust-related fixes. 2022 Sep 30
1.3 Custom background shader, some bugfixes. 2022 Nov 3
1.3r1 Fixed rust, python syntax highlighting. 2022 Nov 4
1.3r2 Fixed high CPU usage on some devices. 2022 Dec 7
## License ted is in the public domain (see `LICENSE.txt`). ## Reporting bugs You can report a bug by sending an email to `pommicket at pommicket.com`. If ted is crashing on startup try doing these things: - Delete `~/.local/share/ted/session.txt` or `C:\Users\\AppData\Local\ted\session.txt` - Reset your ted configuration by moving `ted.cfg` somewhere else.