GithubHelp home page GithubHelp logo

ramontayag / vim-copy-filename Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adamwhittingham/vim-copy-filename

0.0 1.0 0.0 4 KB

Vim commands for copy various bits of the path for the current file

Vim Script 100.00%

vim-copy-filename's Introduction

vim-copy-filepath

A tiny bit of Vimscript to add commands for copying the relative path, absolute path, name and directory of the current file.

Installation

Grab your favourite Vim-plugin manager and add this github URL. For example, with the excellent vim-plug you would add:

Plug 'AdamWhittingham/vim-copy-filename'

Commands

:CopyRelativePath copies the relative path of the file (from the directory Vim was opened in to the file) :CopyRelativePathAndLine as above but also appends the line number :CopyAbsolutePath copies the absolute path of the file (the location of the file on the system, relative to the system root) :CopyAbsolutePathAndLine as above but also appends the line number :CopyFileName copies the name of the file :CopyDirectoryPath copies the directory containing the file (same as absolute path without the file name)

Usage

Bind your key shortcut to one of the functions dscribed above:


nmap <leader>cp :CopyRelativePath<CR>
nmap <leader>cl :CopyRelativePathAndLine<CR>
nmap <leader>cP :CopyAbsolutePath<CR>
nmap <leader>cf :CopyFileName<CR>
nmap <leader>cd :CopyDirectoryPath<CR>

Each of the commands calls a function of the same name, so they can also be reused in scripts/functions. For example, you can call CopyRelativePath() to access the underlying function for copying the relative path.

To execute your own script whenever the file path is copied, define the CopyFilepathPost function:

function! CopyFilepathPost(content)
  echo "Filepath was copied: "
  echo a:content
endfunction

vim-copy-filename's People

Contributors

adamwhittingham avatar cgrinds avatar ramontayag avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.