Skip to content

Migrating From Another Plugin

kylechui edited this page Jul 19, 2022 · 3 revisions

Table of Contents


Feature Comparison

TODO: Add table comparing features

  • Dot-repeat
  • Smart quotes
  • Reverse jumping

Migrating From vim-surround

The default configuration matches many things in vim-surround; most features in nvim-surround are designed to be an extension of those found in vim-surround, as opposed to completely different behavior. Here's a configuration that gets reasonably close:

require("nvim-surround").setup({
    delimiters = {
        invalid_key_behavior = function(char)
            return { char, char }
        end,
        pairs = {
            ["<"] = false,
        },
        HTML = {
            ["<"] = "type",
        },
    },
})

A few quirks to take note of:

  • In general, extraneous whitespace is ignored for all normal mode surrounds.
    • The command ysa"b for the buffer local str = "test string" would yield local str = ("test string").
    • The command ysibB for the buffer ( some text ) would yield ( {some text} ).
  • HTML-related:
    • When filling out the contents of an HTML tag, < and > are optional.
    • > does not end the user-input, <CR> does.
    • When changing the surrounding tag, the "HTML key" only needs to be pressed once, e.g. cst instead of cstt.
    • To differentiate between changing just the HTML tag type (ignoring attributes) and the whole tag contents (including attributes), the values "type" and "whole" are used in setup. By default, cst will change just the tag type, while csT will change the whole tag contents.

Migrating from vim-sandwich

TODO: Include more detailed information about vim-sandwich

require("nvim-surround").setup({
    keymaps = {
        normal = "sa",
        delete = "sd",
        change = "sr",
    },
})

Migrating from mini.surround

TODO: Add mini.surround configuration, differences

Clone this wiki locally