Skip to main content

Introduction

Opening files​

Pragtical comes with a file browser by default. You can open, rename, move and delete files with it.

With a single left-click, documents open in a tab. Supported images and audio files open in their built-in viewers.

Right-clicking on a file or folder will show more options.

Other than that, you can also open files with ctrl+p. This opens a fuzzy finder with a list of project files.

The editor and project file tree in the One Dark theme

Commands​

Most of Pragtical's functionalities are implemented as commands and exposed by the command palette. The command palette is bound to ctrl+shift+p by default and is used to enter commands and execute them.

The command palette supports fuzzy matching, so you don't need to enter the full name of the command. For instance, to create a new file, you can type new doc and the correct command Core: New Doc will show up as the first choice. You can press up or down to select other commands. If a command is bound to a key shortcut, it will be shown on the right.

The command palette with matching commands and shortcuts

The application menus provide another way to find commands. Tools > Settings opens the searchable configuration interface.

Keyboard shortcuts​

All keyboard shortcuts are handled by the core.keymap module. A key binding maps a "stroke" (e.g. ctrl+q) to one or more commands (e.g. core:quit). When the shortcut is pressed Pragtical will iterate each command assigned to that key and run the predicate function for that command — if the predicate passes it stops iterating and runs the command.

A new mapping can be added by your user module as follows:

local keymap = require "core.keymap"
keymap.add { ["ctrl+q"] = "core:quit" }

A list of default mappings can be viewed in Keymap.

Multiple selections (multiple cursors)​

Pragtical supports multiple cursors to edit multiple lines at once. You insert more cursors by ctrl+left-button. To insert cursors upwards or downwards, use ctrl+shift+up or ctrl+shift+down.

Editing several selections at once

Cursor movement, deletion, selection, and wrapping keep displayed characters together, including combining marks and multi-codepoint emoji. Press alt+v to center the active cursor vertically.

Find and replace​

As any other editor Pragtical has built-in support for search and replace. The following features are supported:

  • Case-sensitivity (ctrl+i)
  • Whole word matching (ctrl+shift+w)
  • Lua patterns matching
  • Regex matching (ctrl+shift+i)
  • Replace in selection (ctrl+alt+i)

To find a certain word, you can use ctrl+f. This opens the search panel for the current document. After entering the text, you can press enter to find the first match. The matched text will be selected. To find the next match, press f3 or enter, going to the previous match can be performed by pressing shift+f3 or shift+enter.

To find and replace text on currently opened text document, press ctrl+r. Enter the search and replacement text in the panel.

The find text prompt

Project search and replace​

Finding text across multiple files can be useful. To do this in Pragtical, press ctrl+shift+f. Pragtical opens the project search panel, docked at the left by default. To open the file containing the match, you can click the entries or navigate them using the keyboard keys: up, down, left, right and enter.

With no explicit path, the search includes all open project directories. Choose a path to restrict its scope. Plain text and regular expressions are supported. Select replacement targets using the result checkboxes and review them before replacing. See Project Search for filters, split opening, and centered or tabbed layouts.

Project search result tab

Line endings​

Some application may require a specific type of line ending. To change the line ending of a file, you can use the command doc:toggle-line-ending or click the LF / CRLF entry on the status bar. This should toggle between LF and CRLF which corresponds to Unix and Windows style line endings.

Button to change line endings

Indentation​

Pragtical should automatically detect the indentation of the current file and apply it when pressing tab. However, you can change the indentation size by left-clicking the Spaces / Tabs entry on the status bar. You can also change the type of the indentation by right-clicking the entry. The settings will not apply to existing text.

Changing the indentation of the file

Projects​

Pragtical centers around the concept of projects — a project contains your code and project-specific configuration. A project contains at least one project directory. Project directories are where your code is stored.

To use open a directory as a project, the directory name can be passed as a command-line argument or the directory can be dragged onto either the executable or a running instance. Once loaded, the project can be changed using the command core:change-project-folder. The command will close all the documents currently opened and switch to the new project. If you want to open a project in a new window, the command core:open-project-folder will open a new editor window with the selected project.

Projects may contain multiple directories. To add a directory to the current project, you can use the command core:add-directory. Once the directory is added to the project, you can browse its file on the file browser and fuzzy finder.

Pragtical automatically saves the workspace layout and restores it when you return to the project. Workspace Sessions explains saved sessions and backups of unsaved documents.