Skip to content

Commit 3035297

Browse files
committed
patchy: auto-merge pull request helix-editor#11164
`patchy` is a tool which makes it easy to declaratively manage personal forks by automatically merging pull requests. Check it out here: https://github.com/NikitaRevenco/patchy
2 parents e7c5d6f + c5a06ef commit 3035297

File tree

10 files changed

+1452
-699
lines changed

10 files changed

+1452
-699
lines changed

book/src/commands.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Commands
22

33
- [Typable commands](#typable-commands)
4+
- [Using variables](#using-variables-in-typable-commands)
45
- [Static commands](#static-commands)
56

67
## Typable commands
@@ -9,6 +10,35 @@ Typable commands are used from command mode and may take arguments. Command mode
910

1011
{{#include ./generated/typable-cmd.md}}
1112

13+
14+
### Using variables in typable commands
15+
16+
Helix provides several variables that can be used when typing commands or creating custom shortcuts. These variables are listed below:
17+
18+
| Variable | Description |
19+
| --- | --- |
20+
| `%{basename}` or `%{b}` | The name and extension of the currently focused file. |
21+
| `%{dirname}` or `%{d}` | The absolute path of the parent directory of the currently focused file. |
22+
| `%{cwd}` | The absolute path of the current working directory of Helix. |
23+
| `%{repo}` | The absolute path of the VCS repository helix is opened in. Fallback to `cwd` if not inside a VCS repository|
24+
| `%{filename}` or `%{f}` | The absolute path of the currently focused file. |
25+
| `%{filename:rel}` | The relative path of the file according to `cwd` (will give absolute path if the file is not a child of the current working directory) |
26+
| `%{filename:repo_rel}` | The relative path of the file according to `repo` (will give absolute path if the file is not a child of the VCS directory or the cwd) |
27+
| `%{ext}` | The extension of the current file |
28+
| `%{lang}` | The language of the current file |
29+
| `%{linenumber}` | The line number where the primary cursor is positioned. |
30+
| `%{cursorcolumn}` | The position of the primary cursor inside the current line. |
31+
| `%{selection}` | The text selected by the primary cursor. |
32+
| `%sh{cmd}` | Executes `cmd` with the default shell and returns the command output, if any. |
33+
34+
#### Example
35+
36+
```toml
37+
[keys.normal]
38+
# Print blame info for the line where the main cursor is.
39+
C-b = ":echo %sh{git blame -L %{linenumber} %{filename}}"
40+
```
41+
1242
## Static Commands
1343

1444
Static commands take no arguments and can be bound to keys. Static commands can also be executed from the command picker (`<space>?`). The built-in static commands are:

book/src/generated/typable-cmd.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
| Name | Description |
22
| --- | --- |
33
| `:quit`, `:q` | Close the current view. |
4+
| `:echo` | Print the processed input to the editor status |
45
| `:quit!`, `:q!` | Force close the current view, ignoring unsaved changes. |
56
| `:open`, `:o`, `:edit`, `:e` | Open a file from disk into the current view. |
67
| `:buffer-close`, `:bc`, `:bclose` | Close the current buffer. |

0 commit comments

Comments
 (0)