qwavies/smart-backspace.nvim

github github
editing-support
stars 8
issues 0
subscribers 0
forks 0
CREATED

UPDATED


🚀 Demo

https://github.com/user-attachments/assets/395f18ee-1346-4ac2-8b5c-79597cffe995

📦 Installation

📋 Requirements

  • Neovim 0.8.0 or higher

[!WARNING] If using with nvim-autopairs, in opts, ensure that map_bs = false.

For 💤 lazy.nvim users:

{
    "qwavies/smart-backspace.nvim"
}

For 📦 packer.nvim users:

use {
    "qwavies/smart-backspace.nvim"
}

For 🔌 vim-plug users:

Plug "qwavies/smart-backspace.nvim"

⚙ Configuration

💤 Lazy Loading

If you want to lazy load Smart Backspace, you could set a event condition. For example, if you use lazy.nvim:

{
    "qwavies/smart-backspace.nvim",
    event = {"InsertEnter", "CmdlineEnter"}
}

🧩 Default configuration

Using lazy.nvim:

{
    "qwavies/smart-backspace.nvim",
    opts = {
        enabled = true, -- enables/disables smart-backspace
        silent = true, -- if set to false, it will send a notification if smart-backspace is toggled
        disabled_filetypes = { -- filetypes to automatically disable smart-backspace
            "py",
            "hs",
            "md",
            "txt",
        }
    }
}

⚡ Toggling smart-backspace

Using the :SmartBackspaceToggle command, smart-backspace can be toggled on/off.

If you want to set a keybind to toggle smart-backspace, you can implement the following into your neovim config:

vim.keymap.set("n", "<leader>bs", "<cmd>SmartBackspaceToggle<CR>", { desc = "Toggle Smart Backspace" })

👨‍💻 Planned Changes/Additions

  • A :SmartBackspaceToggle command
  • True compatibility with nvim-autopairs, or act as an alternative
    • Delete pairs of brackets like nvim-autopairs
    • Remove the need to set map_bs = false
  • Using <C-BS> to use as a regular backspace
  • User configuration for more flexibility (feel free to recommend me more configuration changes!)