Coder Social home page Coder Social logo

search-in-visual-selection.nvim's Introduction

search-in-visual-selection.nvim

This Neovim plugin provides an expression-mapping that restricts search to the current visual selection.

Why?

Vim/Neovim lets you search in the visual selection by adding the %V pattern element to the search pattern. This has a little problem: as soon as you use visual mode again, the matches will disappear, which is annoying if your workflow relies on seeing the matches and using the gn text object to change them.

This plugin solves that by problem by instead using the %l and %v pattern elements to restrict the search to the current visual selection.

Mappings

This plugin does not create any mappings. Add one yourself:

vim.keymap.set('x', 'g/', '<Plug>(search-in-visual-selection)')

Usage

Use visual mode to choose the selection in which you want to search. Press g/. The / command-line will appear and be prepopulated with a very ugly looking string such as

\v%\>19l%\<22l%\>9v%\<32v

Note that this uses very magic mode and in particular this way of doing it enables incsearch.

Requirements

Developed and tested on Neovim 0.8.1.

Bugs

  • If the blockwise visual selection goes to the end of the line (using $), then this is not always recognized correctly, since Vim for some reason does not expose this information.
  • Character-wise visual mode for more than one line is treated like visual line mode.

Credits

I got the basic idea from vis, but I wanted something in lua that supports incsearch and doesn't try to hide the pattern from me.

search-in-visual-selection.nvim's People

Contributors

bagohart avatar

Stargazers

Yuta Katayama avatar

Watchers

 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.