right_align


Ⅰ. 插件描述

Right alignment of string under cursor

Ⅱ. 基本信息

创建日期:  2011-09-04
使用用户:  3
Github星:  1
插件作者:  Alexey Radkov

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

This script can be used to align the line under cursor to the right border. The value of the right border column can be specified using global varialbe g:RightAlign_RightBorder in your .vimrc file, for example:

let g:RightAlign_RightBorder = 80

If g:RightAlign_RightBorder is not set then value of option textwidth will be used. Alignment to the right border means that the right edge of the string will not exceed the specified value but will be as close as possible according to your shiftwidth and shiftround settings. For example if shiftwidth is 4, shiftround is set, g:RightAlign_RightBorder is 80 and length of the current line is 14, then first non-space character of this line will be moved to 65th column. This behaviour differs from that of builtin command :right.

Since version 0.5 the shiftround behaviour is active even If you did not set option shiftround. This is due to default value of variable g:RightAlign_ShiftRound is equal 1. If you do not want shiftround behaviour then put in your .vimrc line

let g:RightAlign_ShiftRound = 0

The script provides single command RightAlign with an optional argument. The optional argument can be set to 'kc' in order to make script function keep cursor on the same character of the line when moving it: this is especially useful in insert mode.

To use script efficiently you can choose to use mappings in insert and normal mode, for example

imap <silent> <C-b>    <Plug>RightAlign
nmap <silent> <C-k>b    :RightAlign<CR>
vmap <silent> <C-k>b    :RightAlign<CR>

Now when you press ^b in insert mode the line under cursor will be aligned to the right according to values of the g:RightAlign_RightBorder or textwidth, cursor position will not change in relation to the content of the string. This mapping can be regarded as addition to existing commands ^d, ^t and ^f in insert mode. The second and third mappings enable RightAlign in normal and visual modes respectively when pressing ^kb. In normal mode a range value may be specified to right-align multiple lines at once, for example entering 10^kb will right-align the current line and 9 lines below it.

添加新评论