2023-05-16 14:38:16 +03:00
2023-05-15 13:32:08 +03:00
2023-05-16 11:32:03 +03:00
2023-05-16 11:32:03 +03:00
2023-05-15 21:02:50 +03:00
2023-05-15 13:32:08 +03:00
2023-05-16 14:38:16 +03:00
2023-05-15 02:09:42 +03:00
2023-05-15 02:09:42 +03:00
2023-05-15 02:09:42 +03:00
2023-05-15 02:09:42 +03:00
2023-05-15 02:09:42 +03:00
2023-05-16 11:36:11 +03:00
2023-05-15 02:09:42 +03:00
2023-05-15 02:09:42 +03:00
2023-05-16 14:38:16 +03:00
2023-05-16 14:38:16 +03:00
2023-05-15 13:32:08 +03:00

text-transform.nvim

Common text transformers for nvim - switch between camelCase, PascalCase, snake_case, and more!

Demonstration

Features

Transform the current word or selection between multiple case types. Need to easily replace myVar with my_var or vice versa? This plugin is for you!

  • Works on current word in Normal Mode
  • Works on selection in Visual Mode
Transformation Example Inputs Output
camelCase my_var, my-var, MyVar myVar
PascalCase my_var, my-var, myVar MyVar
snake_case myVar, my-var, MyVar my_var
kebab-case my_var, myVar, MyVar my-var
dot.case my_var, my-var, MyVar my.var
Title Case my_var, my-var, MyVar My Var
CONST_CASE my_var, my-var, MyVar MY_VAR

📋 Installation

Package manager Snippet

wbthomason/packer.nvim

-- stable version
use { "chenasraf/text-transform.nvim", tag = "*" }
-- dev version
use { "chenasraf/text-transform.nvim" }

junegunn/vim-plug

-- stable version
Plug "chenasraf/text-transform.nvim", { "tag": "*" }
-- dev version
Plug "chenasraf/text-transform.nvim"

folke/lazy.nvim

-- stable version
require("lazy").setup({{ "chenasraf/text-transform.nvim", version = "*" }})
-- dev version
require("lazy").setup({ "chenasraf/text-transform.nvim" })

☄ Getting started

To get started, install the plugin via your favorite package manager.

  1. Use the following code to setup in any loaded .lua file

    require('text-transform').setup({
        -- custom settings
    })
    
  2. Either make a selection using Visual mode, or just have your cursor stand on a desired word.

    Then, use the mapped key (default: <Leader>~) to open the transform options in a popup.

  3. Select the desired transform and you're done!

⚙ Configuration

Click to unfold the full list of options with their default values

Note

: The options are also available in Neovim by calling :h TextTransform.options

require("text-transform").setup({
  -- Prints useful logs about what event are triggered, and reasons actions are executed.
  debug = false,
  -- Keymap to trigger the transform.
  keymap = {
    -- Normal mode keymap.
    ["n"] = "<Leader>~",
    -- Visual mode keymap.
    ["v"] = "<Leader>~",
  },
})

🧰 Commands

Use the following as example, you can mix & match the different replacement functions with the desired transform function.

Normally you wouldn't need to call this, as you would just use the keymap you used in setup().

Command Description
:lua TextTransform.replace_word(TextTransform.camel_case) Replaces selected word with camelCase version.
:lua TextTransform.replace_selection(TextTransform.snake_case) Replaces visual selection with snake_case version.

⌨ Contributing

I am developing this package on my free time, so any support, whether code, issues, or just stars is very helpful to sustaining its life. If you are feeling incredibly generous and would like to donate just a small amount to help sustain this project, I would be very very thankful!

Buy Me a Coffee at ko-fi.com

I welcome any issues or pull requests on GitHub. If you find a bug, or would like a new feature, don't hesitate to open an appropriate issue and I will do my best to reply promptly.

If you are a developer and want to contribute code, feel free to fork this repository and make some changes to create a PR, I will do my best to merge your code if it is appropriate.

Description
Common text transformers for neovim - switch between camelCase, PascalCase, snake_case, and more!
Readme MIT 267 KiB
Languages
Lua 96.2%
Makefile 2.8%
Shell 1%