download

Sign in or create your account | Project List | Help

download Git Source Tree

Root/copypath.vim

1" copypath.vim : Copy current editing file path to clipboard.
2"
3" Name Of File: copypath.vim
4" Maintainer: omi taku <mail@nanasi.jp>
5" URL: http://nanasi.jp/
6" Script URL: http://www.vim.org/scripts/script.php?script_id=1456
7" Last Change: 2009/12/16
8" Version: 1.0
9"
10" Installation:
11" 1. Unzip copypath.zip ,
12" and extract there to your vim runtimepath directory ,
13" $HOME/vimfiles/plugin or $HOME/.vim/plugin directory directory.
14"
15" Refer to ':help add-plugin', ':help add-global-plugin' and ':help runtimepath'
16" for more details about Vim plugins.
17"
18" 2. Restart Vim.
19" 3. To run this script, Vim needs to be compiled with "+clipboard" option.
20"
21" Usage:
22" This script adds two new command ":CopyPath" and ":CopyFileName".
23" You can use the ":CopyPath" command to copy file path to clipboard,
24" and you can use the ":CopyFileName" command to copy file name to clipboard.
25"
26" :CopyPath
27" copy current editing file full path to clipboard.
28" And, if you set g:copypath_copy_to_unnamed_register option to 1 then,
29" copy file full path to unnamed register too.
30" Default, not copy to unnamed register.
31"
32" :CopyFileName
33" copy current editing file name to clipboard.
34" And, if you set g:copypath_copy_to_unnamed_register option to 1 then,
35" copy file name to unnamed register too.
36" Default, not copy to unnamed register.
37"
38" Configuration:
39" g:copypath_copy_to_unnamed_register
40" set this option value to 1 then, copy file path and name to unnamed register too.
41" >
42" let g:copypath_copy_to_unnamed_register = 1
43" <
44"
45" Note:
46" o To run this script, Vim needs to be compiled with "+clipboard" option.
47"
48" History:
49" 1.0 o change uploading archive file format to zip format.
50" 0.2 o unnamed register copy option is added.
51" 0.1.2 o document is updated.
52" 0.1.1 o fix bug.
53" 0.1 o Initial upload.
54
55
56" if plugin is already loaded then, not load plugin.
57if exists("g:loaded_copypath")
58    finish
59endif
60let g:loaded_copypath = 1
61
62" if option is set then use open.
63if !exists('g:copypath_copy_to_unnamed_register')
64    let g:copypath_copy_to_unnamed_register = 0
65endif
66
67function CopyPath()
68    let @*=expand('%:p')
69    " copy unnamed register.
70    if g:copypath_copy_to_unnamed_register
71        let @"=expand('%:p')
72    endif
73endfunction
74
75function CopyFileName()
76    let @*=expand('%:t')
77    " copy unnamed register.
78    if g:copypath_copy_to_unnamed_register
79        let @"=expand('%:t')
80    endif
81endfunction
82
83command! -nargs=0 CopyPath call CopyPath()
84command! -nargs=0 CopyFileName call CopyFileName()
85
86finish
87
88" vim: set ts=4 sts=4 sw=4 et nowrap :
89

Archive Download this file

Branches:
master