2021-04-05 15:18:43 +09:00
# Usage
2021-06-22 10:36:29 +05:30
(Currently not fully documented, see the [keymappings ](./keymap.md ) list for more.)
2021-10-27 21:23:46 -04:00
See [tutor.txt ](https://github.com/helix-editor/helix/blob/master/runtime/tutor.txt ) (accessible via `hx --tutor` or `:tutor` ) for a vimtutor-like introduction.
2021-10-23 11:33:17 +09:00
2021-08-18 06:23:50 +05:30
## Registers
Vim-like registers can be used to yank and store text to be pasted later. Usage is similar, with `"` being used to select a register:
- `"ay` - Yank the current selection to register `a` .
- `"op` - Paste the text in register `o` after the selection.
If there is a selected register before invoking a change or delete command, the selection will be stored in the register and the action will be carried out:
- `"hc` - Store the selection in register `h` and then change it (delete and enter insert mode).
- `"md` - Store the selection in register `m` and delete it.
### Special Registers
| Register character | Contains |
| --- | --- |
| `/` | Last search |
| `:` | Last executed command |
| `"` | Last yanked text |
2021-11-28 02:21:40 +01:00
| `_` | Black hole |
2021-08-18 06:23:50 +05:30
> There is no special register for copying to system clipboard, instead special commands and keybindings are provided. See the [keymap](keymap.md#space-mode) for the specifics.
2021-11-28 02:21:40 +01:00
> The black hole register works as a no-op register, meaning no data will be written to / read from it.
2021-08-18 06:23:50 +05:30
2021-06-22 10:36:29 +05:30
## Surround
Functionality similar to [vim-surround ](https://github.com/tpope/vim-surround ) is built into
helix. The keymappings have been inspired from [vim-sandwich ](https://github.com/machakann/vim-sandwich ):

- `ms` - Add surround characters
- `mr` - Replace surround characters
- `md` - Delete surround characters
`ms` acts on a selection, so select the text first and use `ms<char>` . `mr` and `md` work
on the closest pairs found and selections are not required; use counts to act in outer pairs.
2022-01-22 09:34:19 -06:00
It can also act on multiple selections (yay!). For example, to change every occurrence of `(use)` to `[use]` :
2021-06-22 10:36:29 +05:30
- `%` to select the whole file
- `s` to split the selections on a search term
- Input `use` and hit Enter
- `mr([` to replace the parens with square brackets
Multiple characters are currently not supported, but planned.
2021-07-03 06:37:49 +05:30
## Textobjects
2021-10-23 08:11:19 +05:30
Currently supported: `word` , `surround` , `function` , `class` , `parameter` .
2021-07-03 06:37:49 +05:30

2021-10-23 08:11:19 +05:30

2021-07-03 06:37:49 +05:30
- `ma` - Select around the object (`va` in vim, `<alt-a>` in kakoune)
- `mi` - Select inside the object (`vi` in vim, `<alt-i>` in kakoune)
| Key after `mi` or `ma` | Textobject selected |
| --- | --- |
| `w` | Word |
2021-11-07 19:54:39 -05:00
| `W` | WORD |
2021-07-03 06:37:49 +05:30
| `(` , `[` , `'` , etc | Specified surround pairs |
2021-10-23 08:11:19 +05:30
| `f` | Function |
| `c` | Class |
| `p` | Parameter |
Note: `f` , `c` , etc need a tree-sitter grammar active for the current
document and a special tree-sitter query file to work properly. [Only
some grammars](https://github.com/search?q=repo%3Ahelix-editor%2Fhelix+filename%3Atextobjects.scm& type=Code& ref=advsearch& l=& l=)
currently have the query file implemented. Contributions are welcome !