inflector.vim


Ⅰ. 插件描述

Simple vim plugin to apply common text transformations

Ⅱ. 基本信息

创建日期:  2017-04-02
使用用户:  3
Github星:  3
插件作者:  Ivan Karl

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

Inflector.vim

Build Status

This might at some point become a real plugin, right now it's just a little
project to learn vimscript.

The idea is to have a set of functions that present similar functionality as
ActiveSupport::Inflector and make it easier to go from something
like 'some_var' to 'SOME_VAR' or 'SomeVar' to 'some_var', etc.

![inflector.vim in
action](https://raw.github.com/farfanoide/img/master/inflector.vim/inflector.vim.gif)

Why?

Because it seemed simple enough for a first approach into vimscript and because
available options require either python or ruby.

Installation:

Probably any plugin manager will work.

With vim-plug:

Plug 'farfanoide/inflector.vim'

With Vundle:

Plugin 'farfanoide/inflector.vim'

With dein:

call dein#add('farfanoide/inflector.vim')

Usage:

Inflector does not ship with any mappings so in order to use it you have to add
some to your vimrc. To have the plugin create them for you, just set
g:inflector_mapping, for example:

let g:inflector_mapping = 'gI'

Or if you want, set them manually:

nmap gI <Plug>(Inflect)
vmap gI <Plug>(Inflect)

Done, now you can gI some text (stands for go Inflect).
With those mappings you can call the Inflect function in normal mode passing it
a text object or a motion, IE: gIiW, or gI/searchsomething. Inflector will
ask you for the type of conversion you want to apply.

Available inflections:

The idea behind the plugin is to have a sort of "Text Multiplexer" which can
translate from any of the recognized patterns to any other, meaning: it should
be the able to go from PascalCase to CONSTANT or camelCase and viceversa.

This is done by having a common representation which currently is based on a
list so SomeText translates into ['some', 'text'] and from there it's
trivial to convert to any other representation.

InflectionAliasInputCommandOutput
Dotify.someTextToWorkgIiw.some.text.to.work
Dasherize-some_text_to_workgIiw-some-text-to-work
Underscore_some text to workgI$_some_text_to_work
CamelizecSome Text To WorkgI$csomeTextToWork
ConstantizeCsome text to workgI$CSOME_TEXT_TO_WORK
PascalizePsome.text.to.workgIiWPSomeTextToWork
Titleizetsome text to workgI$tSome Text To Work
NormalizenSOME_TEXT_TO_WORKgI$nsome text to work
Slashify/SOME_TEXT_TO_WORKgIiw/some/text/to/work
FreeBallItfsome text to workgI$f&some&text&to&work
Privatizepsome_vargI$p_some_var

Special Inflections:

Privatize is handeled differently, it only check if the text being transformed
already starts with an underscore.

FreeBallIt allows the user to specify any character to join the separated
words.

Tests

So far, tests are ran via Vader, open
inflector.vader and run :Vader

License:

See the LICENSE.

Contributing:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

TODO:

  • [ ] add repeat support
  • [ ] add vim help?

<!-- links -->

<!-- end links -->

添加新评论