Ⅰ. 插件描述
Create a duplicate clone of the current buffer.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/clone'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/clone'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/clone'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/clone
Ⅳ. 文档说明
DESCRIPTION
Often, it is efficient to base a new file (e.g. unit test, meeting minutes) on
an existing one, and just apply the changes instead of re-creating the entire
- In Vim, one can create a duplicate copy of the current buffer via
:write {newfile} or :saveas {newfile}. But the former doesn't
automatically open the cloned file, whereas with the latter, you're losing the
buffer containing the original file. Also, the identical clone is immediately
persisted, which may confuse automated build tools (or yourself, should you
get interrupted and forget to make the actual modifications). Transferring the
buffer contents via :yank is also cumbersome and clobbers a register.
This plugin offers a :CloneAs command that duplicates the current buffer (or
only parts of it) without persisting the clone right away (only on :w), and
keeping the original buffer loaded and unmodified inside Vim (with
:SCloneAs, it'll even be kept displayed in a window).
Oftentimes, duplication in source code is a code smell. Please use this plugin
responsibly ;-)
SEE ALSO
The cloneSimilar.vim plugin (vimscript #4897) adds additional command
variants powered by the EditSimilar.vim (vimscript #2544) plugin.
USAGE
:[range]CloneAs {file} Duplicate and edit the current buffer / specified
lines with a new name, keep the existing one.
:[range]SCloneAs {file} Duplicate and split the current buffer / specified
lines with a new name, keep the existing one.
The original cursor position / window view will be
kept, as well as the 'fileformat', 'fileencoding' and
'filetype' settings of the original buffer.