CommentFrame.vim


Ⅰ. 插件描述

Mirror of http://www.vim.org/scripts/script.php?script_id=4317

Ⅱ. 基本信息

创建日期:  2012-04-18
使用用户:  1
Github星:  27
插件作者:  Benjamin L

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/cometsong/commentframe.vim

Ⅳ. 文档说明

"~~~~~~~~~~~~~~~~~~"
" CommentFrame! "
" "
" Copyright (c) 2012 Benjamin Leopold "
" All rights reserved. "
" "
" Public Domain, same license as Vim. "
" see: http://vimdoc.sourceforge.net/htmldoc/uganda.html#license "
"~~~~~~~~~~~~~~~~~~"
"~~~~~~ by cometsong <benjamin at cometsong dot net> ~~~

"~~~~~~~~~~~~~~~~~~"
" "
" This is a simple plugin to generate fancy-looking comments/section dividers "
" with centered titles and append them at the current cursor position. "
" "
" Also CommentRight => line of comment (customizable for diff langs) with "
" string arg put on right end of line. "
" "
" To customize further, unmapping of default keysets can be done, plus "
" creating any new combinations of frame types by using the custom "
" CommentFrameCustom and CommentRightCustom functions in your vimrc. "
" See below for details. "
" "
" For latest developments, any mods, pull requests, etc, see: "
" https://github.com/cometsong/CommentFrame.vim "
" "
"~~~~~~~~~~~~~~~~~~"
" inspired by: makesd/makecsd by Chase Venters script: "
" http://www.vim.org/scripts/script.php?script_id=3253 "
"~~~~~~~~~~~~~~~~~~"

Plugin Configuration:
g:CommentFrame_SkipDefaultMappings let =1 to not use default keymaps

g:CommentFrame_TextWidth set global default width of comment

                                     frames and lines; always modifiable
                 using the `...Custom` functions

Basic Usage:

The default keymappings are setup for a custom function to create a CommentFrame
and also a CommentRight line. All keymapping start with <Leader>, all default
frames and right lines are 80 characters.

Key     Command Name                Result
---     --------------------------  ----------------------------------------
fcs     CommentFrameSlashes         border: //****************************//
fcS     CommentFrameSlashStar       border: /******************************/
fch     CommentFrameHashDash        border: #------------------------------#
fcH     CommentFrameHashEqual       border: #==============================#
fcq     CommentFrameQuoteDash       border: "------------------------------"
fcQ     CommentFrameQuoteTilde      border: "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

frh     CommentRightHash            line: #~~~~~~~~~~~~~~~~~~~~~ title ~~~~~
frs     CommentRightSlashes         line: //~~~~~~~~~~~~~~~~~~~~ title ~~~~~
frS     CommentRightSlashStar       line: /*~~~~~~~~~~~~~~~~~~ title ~~~~~*/
frq     CommentRightQuote           line: "~~~~~~~~~~~~~~~~~~~~~ title ~~~~~

These defaults can be unmapped, remapped or preserved, as you see fit or can be
not mapped at all using the config variable mentioned above.

New styles and keymappings can be added using the following lines in your vimrc:

command! -nargs=+ CommentFrameSlashMeDown :call CommentFrame#Custom('//', '//', 80, '*', '_', 0, <args>)
call CommentFrame#MapKeys('ni', 'cfs', ':CommentFrameSlashMeDown ""<Left>')

This will create a new command and a new key mapped in modes normal (n) and
insert (i) modes, as designeted in the first MapKeys arg, then 'cfC' as the keys
to map, and the command to be run with that keypress, or by using the command
from the ':' command line.

Below is the MapKeys call for direct access to the CommentFrameCustom
command, if only a keymapping is desired, not another usable command.

call CommentFrame#MapKeys("n", "mykeys", ":CommentFrameCustom '!','...',80,':','>',3,''<Left>")

Have fun stormin the castle!

添加新评论