Giter Club home page Giter Club logo

nvim-surround's Introduction

nvim-surround

Surround selections, stylishly ๐Ÿ˜Ž

README_demo_3.mp4

โœจ Features

  • Add/delete/change surrounding pairs
    • Function calls and HTML tags out-of-the-box
  • Dot-repeat previous actions
  • Set buffer-local mappings and surrounds
  • Jump to the nearest surrounding pair for modification
  • Use a single character as an alias for several text-objects
    • E.g. q is aliased to `,',", so csqb replaces the nearest set of quotes with parentheses
  • Surround using powerful pairs that depend on user input
  • Modify custom surrounds
    • First-class support for Vim motions, Lua patterns, and Tree-sitter nodes
  • Highlight selections for visual feedback

๐Ÿ”’ Requirements

  • Neovim 0.8+
  • [Recommended] If nvim-treesitter is installed, then Tree-sitter nodes may be surrounded and modified, in addition to just Vim motions and Lua patterns
  • [Recommended] If nvim-treesitter-textobjects is installed, then Tree-sitter text-objects can be used to define surrounds, simplifying configuration

๐Ÿ“ฆ Installation

use({
    "kylechui/nvim-surround",
    tag = "*", -- Use for stability; omit to use `main` branch for the latest features
    config = function()
        require("nvim-surround").setup({
            -- Configuration here, or leave empty to use defaults
        })
    end
})

๐Ÿš€ Usage

The three "core" operations of add/delete/change can be done with the keymaps ys{motion}{char}, ds{char}, and cs{target}{replacement}, respectively. For the following examples, * will denote the cursor position:

    Old text                    Command         New text
--------------------------------------------------------------------------------
    surr*ound_words             ysiw)           (surround_words)
    *make strings               ys$"            "make strings"
    [delete ar*ound me!]        ds]             delete around me!
    remove <b>HTML t*ags</b>    dst             remove HTML tags
    'change quot*es'            cs'"            "change quotes"
    <b>or tag* types</b>        csth1<CR>       <h1>or tag types</h1>
    delete(functi*on calls)     dsf             function calls

Detailed information on how to use this plugin can be found in :h nvim-surround.usage.

โš™๏ธ Configuration

The default configuration is found here. Simply call require("nvim-surround").setup or require("nvim-surround").buffer_setup with the desired options.

More information on how to configure this plugin can be found in :h nvim-surround.configuration.

Contributing

See the contributing file.

Shoutouts

nvim-surround's People

Contributors

kylechui avatar smjonas avatar gelio avatar adoyle-h avatar felisnivalis avatar diomendius avatar rafamadriz avatar ouuan avatar catgoose avatar philopence avatar shurizzle 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.