Giter Site home page Giter Site logo

nvim-better-n's Introduction

nvim-better-n

Repeat movement commands using n in the same vein that . repeats action commands.

About

nvim-better-n attempts address a problem with Vim, which is that almost every single binding is used by default, for (often) very niche actions. I want to be able to reuse convenient bindings for similar things, reducing both mental overhead as well as opening up more bindings, allowing Vim to be more ergonomic.

It does this by rebinding n (which is a rather convenient binding), so that it used for multiple different movement commands, in the same vein . repeats action commands.

For example, if we jump to the next hunk, using ]h, we can repeat that command using n, allowing for far easier "scrolling" using that motion without coming up with a bind that is easier to repeat.

Using this binding for that motion would, without this plugin, be rather cumbersome in the cases were you wanted to press it multiple times.

It should also be noted that this frees up both ;, and , for other actions, as n will instead handle their current task.

Install

Install as usual, using your favourite plugin manager.

use "jonatan-branting/nvim-better-n"

Setup

require("better-n").setup(
  {
    -- These are default values, which can be omitted.
    -- By default, the following mappings are made repeatable using `n` and `<S-n>`:
    -- `f`, `F`, `t`, `T`, `*`, `#`, `/`, `?`
    disable_default_mappings = false,
  }
)

vim.nvim_create_autocmd("User", {
  pattern = "BetterNMappingExecuted",
  callback = function(args)
    -- args.data.key and args.data.mode are available here
  end
})

-- You create repeatable mappings like this:
local hunk_navigation = require("better-n").create(
  {
    next =  require("gitsigns").next_hunk,
    previous = require("gitsigns").prev_hunk
  }
)

vim.keymap.set({ "n", "x" }, "]h", hunk_navigation.next)
vim.keymap.set({ "n", "x" }, "[h", hunk_navigation.previous)

nvim-better-n's People

Contributors

jonatan-branting avatar weofiw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.