Git Product home page Git Product logo

visual-surround.nvim's Introduction

Visual-surround.nvim

Why another surround plugin?

The answer is simple: because I only ever used the 'surround visual selection' feature of (btw incredible) plugins such as nvim-surround or mini.surround. I wanted to create the plugin that does a similar thing to that one vsc**e's feature - highlight text that you want to surround with parentheses and just press the ( or ) key.

If you want additional functionalities, such as deleting surrounding characters, changing surrounding characters, or some other advanced features, check out two of the plugins mentioned above.

๐Ÿ“บ Showcase

visual-surround_showcase.mp4

๐Ÿ“‹ Installation

lazy:

{
    "NStefan002/visual-surround.nvim",
    config = function()
        require("visual-surround").setup({
            -- your config
        })
    end,
    -- or if you don't want to change defaults
    -- config = true
}

packer:

use({
    "NStefan002/visual-surround.nvim",
    config = function()
        require("visual-surround").setup({
            -- your config
        })
    end,
})

โš™ Configuration

Default config
{
    -- if set to true, the user must manually add keymaps
    use_default_keymaps = true,
    -- will be ignored if use_default_keymaps is set to false
    surround_chars = { "{", "}", "[", "]", "(", ")", "'", '"', "`" },
    -- whether to exit visual mode after adding surround
    exit_visual_mode = true,
}

๐Ÿ‘€ Tips

set some additional keymaps
vim.keymap.set("v", "s<", function()
    -- surround selected text with "<>"
    require("visual-surround").surround("<") -- it's enough to supply only opening or closing char
end)
set new keymaps
require("visual-surround").setup({
    use_default_keymaps = false,
})

local preffered_mapping_prefix = "s"
local surround_chars = { "{", "[", "(", "'", '"', "<" }
local surround = require("visual-surround").surround
for _, key in pairs(surround_chars) do
    vim.keymap.set("v", preffered_mapping_prefix .. key, function()
        surround(key)
    end, { desc = "[visual-surround] Surround selection with " .. key })
end

visual-surround.nvim's People

Contributors

github-actions[bot] avatar nstefan002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

visual-surround.nvim's Issues

backticks not supported

thanks for the plugin.
i like that it's minimalistic.

is it possible for backticks to be supported as well?

start_col must be less than end_col

When you do a regular visual selection that starts at column x and goes backwards, an error occurs

My naive fix that seems to work with little testing is to add this into the Util.get_bounds function before it returns.

    if vline_start > vline_end then
        local temp = vline_start
        vline_start = vline_end
        vline_end = temp
    end
    if vcol_start > vcol_end then
        local temp = vcol_start
        vcol_start = vcol_end
        vcol_end = temp
    end

changing the vline may not be necessary, and this probably breaks other things but it's a start.

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.