Skip to content
/ endec.nvim Public

Neovim encoder/decoder plugin for Base64, Base64URL, URL (percent encoding)

License

Notifications You must be signed in to change notification settings

ovk/endec.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

endec.nvim

A simple Neovim plugin for encoding and decoding text. Supports Base64, Base64URL and URL-encoding (percent-encoding).

Features

  • Encode and decode:
  • Perform encoding/decoding in-place or view decoded text in a popup window.
    • Editing the decoded text in the popup, and writing back automatically re-encodes it.

Requirements

This plugin requires Neovim v0.10 or newer (leveraging built-in Base64 support).

Installation

Installation instructions for popular plugin managers:

Lazy.nvim

{
    "ovk/endec.nvim",
    event = "VeryLazy",
    opts = {
        -- Override default configuration here
    }
}

packer.nvim

use({
    "ovk/endec.nvim",
    config = function()
        require("endec").setup({
            -- Override default configuration here
        })
    end
})

Usage

There are three core operations (available for each encoding):

  • Decode text in-place
  • Decode text and show it in a popup window
  • Encode text in place

The default key mappings setup so that these operations can either be triggered in:

  • Normal mode: for example, gb{motion} to decode Base64 and show decoded text in a popup (more specific example - gbi" to "decode Base64 inside quotes").
  • Visual mode: for example, gB to Base64-encode visually selected text.

EOL

The encoded text can contain encoded EOL characters, which can be either Unix, Windows or Mac style. However, when re-encoded, the plugin will use buffer's current EOL as specified by fileformat. If preserving the original EOL in the encoded text is absolutely necessary, some other tool should be used.

Multi-line Blocks

When re-encoding block of text that consists of multiple lines, the plugin tries to keep number of lines the same. For example, if a block of five lines of Base64 is selected, decoded in a popup and then re-encoded back, the plugin will try to keep it at same five lines, but the lines will be shorter/longer, depending on how the text was edited.

Configuration

The default configuration options are specified and documented here.

By default, all key mappings for all encodings are enabled, but any default mapping can be disabled by setting the corresponding mapping to and empty string (for example - encode_url_inplace = "").

Default Key Mappings

The mappings below work for both visual and normal modes (mapping should be followed by a motion in normal mode).

Mapping Description
gb Decode Base64 in a popup
gyb Decode Base64 in-place
gB Encode Base64 in-place
gs Decode Base64URL in a popup
gys Decode Base64URL in-place
gS Encode Base64URL in-place
gl Decode URL in a popup
gyl Decode URL in-place
gL Encode URL in-place

About

Neovim encoder/decoder plugin for Base64, Base64URL, URL (percent encoding)

Topics

Resources

License

Stars

Watchers

Forks

Languages