vim-copy-filename


Ⅰ. 插件描述

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

Ⅱ. 基本信息

创建日期:  2015-06-06
使用用户:  2
Github星:  1
插件作者:  Adam Whittingham

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'adamwhittingham/vim-copy-filename'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'adamwhittingham/vim-copy-filename'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'adamwhittingham/vim-copy-filename'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/adamwhittingham/vim-copy-filename

Ⅳ. 文档说明

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.

添加新评论