Evaluate selected text as ruby code then print or insert.
I love Ruby, one of the goodness of ruby is it has many way to express Array , String , etc..
When I write other Language such as Python or JavaScript and want to prepare
array [ "a", "b", "c", "d" ]
.
You can write %w(a b c d)
then select text , then execute :RubyEvalInsert
to
insert [ "a", "b", "c", "d" ]
to buffer.
gem install awesome_print
vnoremap <silent> <Space>p :<C-u>RubyEvalPrint<CR>
vnoremap <silent> <Space>i :<C-u>RubyEvalInsert<CR>
nnoremap <silent> <Space>p :<C-u>RubyEvalPrint<CR>
nnoremap <silent> <Space>i :<C-u>RubyEvalInsert<CR>
In following what I want you to try is..
set cursor position to ruby fragment, then execute :RubyEvalInsert
10.times.map {|n| rand(6) + 1}
("A".."Z").to_a.join()
Hash[*%w(port 80 ip 192.168.1.1)]