Skip to content

Maelwalser/oil-copy.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

oil-copy.nvim

An extension for stevearc/oil.nvim that allows you to copy the contents of one or more files, or the recursive contents of entire directories, directly to your system clipboard.

Features

oil-copy-demo.mp4
  • Copy Single Files: In normal mode, place your cursor over a file and copy its entire content to the system clipboard (+ register).

  • Copy Directories: In normal mode, place your cursor over a directory to recursively find all files within it, concatenate their contents, and copy the result to the clipboard.

  • Copy Visual Selections: In visual mode, select multiple files and/or directories. The plugin will copy the contents of all selected files and all files found recursively within any selected directories.

  • Contextual Headers: When copying multiple files (either from a directory or a visual selection), the file path of each file is added as a comment (-- /path/to/file) above its content, making the combined text easy to navigate.

Requirements

  • neovim/nvim-lsp (v0.8+)

  • stevearc/oil.nvim

Installation & Configuration

Here is an example using lazy.nvim.

{
  "maelwalser/oil-copy.nvim",
  dependencies = { "stevearc/oil.nvim" },
  opts = {
    -- You can customize the keymap here
    -- keymap = "<leader>p" -- Uncomment and change to your preferred key
  },
  config = function()
    require("oil-copy").setup()
  end,
}

The plugin is enabled by calling the setup() function. The default keymap for both normal and visual mode is cf.

Usage

Once installed, the plugin sets up keymaps within any oil buffer:

  • Normal Mode:

    • Place your cursor on a file and press cf (or your custom keymap) to copy its contents.

    • Place your cursor on a directory and press cf to copy the recursive contents of all files within that directory.

  • Visual Mode:

    • Select one or more files and/or directories and press cf.

    • This will copy the contents of all selected files and the recursive contents of all files within any selected directories.

About

Copy directory and file contents in oil

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages