Skip to content

backdround/improved-ft.nvim

Repository files navigation

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

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
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
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
local imap = function(key, fn, description)
  vim.keymap.set("i", key, fn, {
    desc = description,
    expr = true,
  })
end

imap("<M-f>", ft.hop_forward_to_char, "Hop forward to a given char")
imap("<M-F>", ft.hop_backward_to_char, "Hop forward to a given char")

imap("<M-t>", ft.hop_forward_to_pre_char, "Hop forward before a given char")
imap("<M-T>", ft.hop_backward_to_pre_char, "Hop forward before a given char")

imap("<M-;>", ft.repeat_forward, "Repeat hop forward to a last given char")
imap("<M-,>", ft.repeat_backward, "Repeat hop backward to a last given char")

About

Improve default f/t hop abilities

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published