vim-sade


Ⅰ. 插件描述

vim-sade. Smooth operators with minimum waste and maximum joy.

Ⅱ. 基本信息

创建日期:  2014-03-02
使用用户:  1
Github星:  10
插件作者:  Sebastián Grignoli

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

" Relatively simple operators can be defines as mappings

" they are called with "normal!", so we must escape special chars with \

" Let's define "Paste before" and "Paste after" operator mappings
call sade#Map("(p","\<esc>`<P")
call sade#Map(")p","\<esc>`>p")

" This one will convert "script" into "<script>|</script>"
" (the | represents the cursor position after invoking)
call sade#Map("Qt", "di<\<esc>gpi>\<esc>mpa</\<esc>gpi>\<esc>`pll\<cr>")
" Let's define an operator function:
call UserOperatorFunc('b','Test')

func! Test()
  " Target text is selected in visual mode now, 
  " you can yank it, delete it or do anything you want
  " including exiting to normal mode with:  exe 'norm! \<esc>'
  
  " Also, you have some predefined variables:
  "  g:UserOperatorLastText        A copy of the selected text
  "  g:UserOperatorStartingLine    Buffer line number of selection start
  "  g:UserOperatorEndingLine      Buffer line number of selection end 
  "  g:UserOperatorStartingColumn  Buffer column number of selection start
  "  g:UserOperatorEndingColumn    Buffer column number of selection end 
  
  " as usual, marks '< and '> are set at the start and end of the selection
  " so you can choose to position yourself at the beginning or end of the 
  " selection when you're done:    
  " go to the beginning:    norm! `<    
  " go to the end:          norm! `> 

  " (in this example we are going to paste into the line below as an argument
  " to a function call)"

  
  exe "norm! \<esc>"
  let @w = "Inspect::view(".g:UserOperatorLastText.");"
  norm! o
  norm! "wp
  "norm! `<
endfun

添加新评论