vim-pivot


Ⅰ. 插件描述

Lets you swap text elements around a pivot, eg (a,b) -> (b,a)

Ⅱ. 基本信息

创建日期:  2013-11-09
使用用户:  1
Github星:  1
插件作者:  Hillel Wayne

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

vim-pivot

Lets you swap text elements around a pivot, eg (a,b) -> (b,a). Still hella buggy.

Use

Pivot maps to <leader>p. Currently it works with w, W, $, and braces. It takes the first element in front of the cursor and the first element behind and swaps them. For example, assuming <leader> is ',':

  • ,pw will map f(a,b) -> f(b,a) if the cursor is over the ','
  • ,pw will map @a = var1 -> @var1 = a if the cursor is over the '='
  • ,pW will map @a = var1 -> var1 = @a if the cursor is over the '='
  • ,p$ will map a + b = c + d -> c + d = a + b if the cursor is over '='

Braces work a little differently. They pivot everything inside the braces, and they'll account for nesting. For example:

  • ,p) will map [a,b+c] -> [b+c,a] if cursor is over ','
  • ,p] will map f(a,g(b+c)) -> f(g(b+c),a) if cursor is over ','. It skips the first set of parenthesis as nested.

TODO

  • Write a comprehensive docfile
  • Fix whitespace issues with pivoting in braces
  • Make cursor return to pivot after pivoting without using a weird control character hack
  • Add support for numbers, so ,p2w will pivot two words
  • Add more mappings
  • Fix more corner cases
  • Add generalized motion support (this will not happen)

添加新评论