Skip to content

junegunn/vim-ruby-x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vim-ruby-x

:RubyX command extends Ruby interface of Vim, making it (marginally) easier to use.

Installation

Use your favorite plugin manager.

  • vim-plug
    1. Add Plug 'junegunn/vim-ruby-x' to .vimrc
    2. Run :PlugInstall

Features

Easier variable access

  • VIM[]
  • VIM[]=
  • VIM.exists?(varname)
  • VIM.fetch(varname, default)
  • VIM.unlet(*varnames)
var1 = VIM['g:var1']
var2 = VIM['g:var2'] || 0

VIM['g:vars'] = { :vars => [var1, var2], :sum => var1 + var2 }

VIM.unlet 'g:var1', 'g:var2'

Shortcuts to VIM::command and VIM::evaluate

  • String#vim!
  • String#vim?
'redraw!'.vim!
count = 'len(g:array)'.vim?

Executing normal mode commands

VIM.normal  'gqip'
VIM.normal! 'gg=G'

Vimscript representation of Ruby values

  • Object#to_v
'hello world'.to_v
  # "hello world"

[1, 2, 3, %w[hello world], { 'hello' => { 'world' => '!' } }].to_v
  # [1, 2, 3, ["hello", "world"], {"hello": {"world": "!"}}]

Calling Vim functions

  • VIM.call(name, *args)
VIM.call(:feedkeys, "\C-c")

Making Ruby code interruptible with CTRL-C

VIM.interruptible do
  begin
    sleep
  rescue Interrupt
    puts 'Interrupted!'
  end
end

Messages

VIM.echo    'Welcome'
VIM.echo    'Apples', :Identifier, ' are ', :Structure, 'red', :Error
VIM.error   'Oops, try again'
VIM.message 'This one is builtin'

About

if_ruby helper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published