roobert/f-string-toggle.nvim

github github
programming-languages-support
stars 35
issues 1
subscribers 3
forks 3
CREATED

UPDATED


:yarn: f-string-toggle

f-string-toggle

A modularised version of this reddit post by u/ddmenddes_ - all credit goes to the original author!

Install

{
  "roobert/f-string-toggle.nvim",
  config = function()
    require("f-string-toggle").setup({
      key_binding = "<leader>f",
      key_binding_desc = "Toggle f-string"
      filetypes = { "python" },
    })
  end,
}

Configure

Disable default mapping

If you would prefer not to use the default key binding, you can set key_binding = false and directly call toggle_fstring(). Here is an example with lazy.nvim:

{
  "roobert/f-string-toggle.nvim",
  keys = {
    { "<leader>fs", function() require("f-string-toggle").toggle_fstring() end, desc = "Toggle f-string" }
  },
  config = function()
    require("f-string-toggle").setup({
      key_binding = false,
    })
  end,
}

If you want to set the mapping outside lazy.nvim, you can use:

vim.keymap.set('n', '<leader>f', function() require('f-string-toggle').toggle_fstring() end, { desc = "Toggle f-string" })

Usage

Within a string press leader-f to toggle if it's an f-string or not.