Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/backdround/improved-ft.nvim

Improve default f/t hop abilities
https://github.com/backdround/improved-ft.nvim

Last synced: about 1 month ago
JSON representation

Improve default f/t hop abilities

Lists

README

        

# Improved-ft.nvim



Tests


Tests

It's a feature-rich, but straight-forward Neovim plugin that improves default
`f/t` hop abilities.

Additional features:
- Works in multiline;
- Works in `insert` mode;
- Has the additional `post` offset;
- Has the ability of stable next / previous hops (don't depend on last hop direction).

### Preview
#### Basic

#### Past a character

#### In insert mode

---

### Basic configuration
```lua
local ft = require("improved-ft")
ft.setup({
-- Maps default f/F/t/T/;/, keys.
-- default: false
use_default_mappings = true,

-- Ignores case of the given characters.
-- default: false
ignore_char_case = true,

-- Takes a last hop direction into account during repetition hops
-- default: false
use_relative_repetition = true,

-- Uses direction-relative offsets during repetition hops.
-- default: false
use_relative_repetition_offsets = true,
})
```
### Advanced configuration

Basic mappings

```lua
local map = function(key, fn, description)
vim.keymap.set({ "n", "x", "o" }, key, fn, {
desc = description,
expr = true,
})
end

map("f", ft.hop_forward_to_char, "Hop forward to a given char")
map("F", ft.hop_backward_to_char, "Hop backward to a given char")

map("t", ft.hop_forward_to_pre_char, "Hop forward before a given char")
map("T", ft.hop_backward_to_pre_char, "Hop backward before a given char")

map(";", ft.repeat_forward, "Repeat hop forward to a last given char")
map(",", ft.repeat_backward, "Repeat hop backward to a last given char")
```

Post character mappings

```lua
local map = function(key, fn, description)
vim.keymap.set({ "n", "x", "o" }, key, fn, {
desc = description,
expr = true,
})
end

map("s", ft.hop_forward_to_post_char, "Hop forward after a given char")
map("S", ft.hop_backward_to_post_char, "Hop backward after a given char")

```

Insert mode mappings

```lua
local imap = function(key, fn, description)
vim.keymap.set("i", key, fn, {
desc = description,
expr = true,
})
end

imap("", ft.hop_forward_to_char, "Hop forward to a given char")
imap("", ft.hop_backward_to_char, "Hop forward to a given char")

imap("", ft.hop_forward_to_pre_char, "Hop forward before a given char")
imap("", ft.hop_backward_to_pre_char, "Hop forward before a given char")

imap("", ft.repeat_forward, "Repeat hop forward to a last given char")
imap("", ft.repeat_backward, "Repeat hop backward to a last given char")
```