sponsor Vim development Vim logo Vim Book Ad

Vicle : Vim - Interpreter Command Line Editor. Like Chimp or Slimv.

 script karma  Rating 131/35, Downloaded by 1598    Comments, bugs, improvements  Vim wiki

created by
Jose Figueroa Martinez
 
script type
utility
 
description
Vim - Interpreter Command Line Editor. Use vim like a front-end for edit commands and send it to an interactive interpreter open in a GNU Screen session or tmux session.

Features:

- Command History, just like a shell
- History save/load
- Can send only selected text or custom selection

I have been using Python, Ruby, Common Lisp, Scheme, Clojure, Ksh, and others interpreters through Vim and Vicle (and GNU Screen or tmux).

Usage:

- Load a Screen session and then load an interpreter (ipython, irb, shell,
  sbcl, clisp, clojure,  etc.) in the shell:
  % screen -S rubySession
  % irb
  >>

- Open Vim with the vicle plugin and type a command (without press ENTER):
  puts "Ruby interpreter"

- Type <C-c><C-c>  or <C-CR> or :VicleSend  to send to the interpreter the
  current line (that can be changed by setting other Selection String).

- If the identifiers of the screen are not set, you are going be asked for
  it (put the session name and window number where your interpreter are.
  All the windows in a Screen session have a unique number.
  You can use TAB key for completion in the Session name):

  Session name: rubySession
  Window number: 0

  In the screen window you are going to see:
  >> puts "Ruby interpreter"
  Ruby interpreter
  => nil

  If you disable the Edition Mode by calling the command :VicleEditionToggle
  the <C-CR> and the other shortcut are going to send all the content of the
  screen and after that, the screen of Vim are going to be cleared, just
  like a normal command line.

- You scroll through the commands with the key <C-Up> and <C-Down>   just
  like the history of the shell.

- Edition Mode
  This mode do not clear the screen after send the command. Also, it send a
  command selected by a custom Selection String that is in the variable

  w:vicle_selection_string

  Edition Mode is 1 (ON) by default.

  By default, vicle in Edition mode send the current line.
  Toggle the Edition Mode using the command :VicleEditionToggle

  The selection string is by default "0v$y": go to column 0, enter visual
  mode, go to the end of line and yank. Always is necesary to end with the
  yank command "y".
  It can be set to "{v}y" to select the current paragraph

- Sending selected text using Vim's Visual Mode
  Just select the text and press <C-CR> or <C-c><C-c> to send the selected
  text without clear the screen. It is the same in Vicle Edition Mode and
  Vicle Not Edicion Mode (send command and clear vim screen)

  Just select the text. Vicle are going to yank it.

- Usefull commands for manage the history. Use absolute paths for history files:
  :VicleHistoryToggle   " activate or deactivate history
  :VicleHistoryClear
  :VicleHistorySize
  :VicleHistorySave
  :VicleHistoryLoad

- To change the screen name and window name use the command
  :VicleSession

- Some global variables that you can define in your .vimrc:

  let g:vicle_session_sn    = 'normal_session_name'
  let g:vicle_session_wn  = 'normal_session_window'
   let g:vicle_use               = 'screen'       " Can be 'screen' or 'tmux'
   let g:vicle_escape_caret      = 0    " If defined as 1 then the characters ^ will be escaped as \^

  let g:vicle_history_active   = 0 " deactivate history
  let g:vicle_edition_mode     = 1 " active edition mode
  let g:vicle_selection_string = "0v$y"  " yank current line

  let g:vicle_hcs             = '~~~your_command_separator~~~'
  let g:vicle_max_buffer        = 300  " work for OSX

Tips:

- If you want to send commands to a Ruby interpreter (irb), open a file like
  work.rb or other with the extension .rb  or set the filetype manually
  :set filetype=ruby

This apply to other languages supported by vim.

- For use Vicle with diferent languages

  autocmd FileType python let w:vicle_selection_string = "0v}y"
  autocmd FileType lisp let w:vicle_edition_mode = 1 | let w:vicle_history_active = 0 | let w:vicle_selection_string = "v%y"
  autocmd FileType clojure let t:vicle_edition_mode = 1 | let t:vicle_history_active = 0 | let t:vicle_selection_string = "v%y" | let t:vicle_session_sn ="session_name" | let t:vicle_session_wn= "window_name.pane_index"

- Use of rlwrap to run the interpreter

  It is known that by trying and testing that running the interpreter with rlwrap improves the performances of vicle.

  Clojure with rlwrap:
  screen -S clojure rlwrap java -cp clojure.jar clojure.main

  Clojure with tmux:
  tmux new-session -s code -n clojure    # session name: code, window name: clojure
   "   In vim, session = code, window=clojure.2   if working in pane 2 of window named "clojure".

- About the limit of size for the buffers to send

  Vicle call many times to Screen when the buffer to send its bigger than 1000 characters. This let vicle to send really big buffers.


Inspired On:

  Slime for Vim from Jonathan Palardy
  http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
  and the work of Jerris Welt
  http://www.jerri.de/blog/archives/2006/05/02/scripting_screen_for_fun_and_profit/
 
install details
Just put it in your vim's plugins directory.

This plugin doesn't work in Windows, as far as I know. I tried to run it on Cygwin but nothing.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vicle.vim 1.3.0 2014-10-01 7.0 Jose Figueroa Martinez - New parameters to select screen or tmux terminal emulators and to know if the caret character (^) must be escaped or not (problem reported by  Stephan Sahm.
- Changed the name of some parameters:
     t:vicle_screen_sn to t:vicle_session_sn
     t:vicle_screen_wn to t:vicle_session_wn
vicle.vim 1.2.2 2011-08-04 7.0 Jose Figueroa Martinez - Bugfix by Markus Dobler from informatik.uni-tuebingen.de, related to the error behavior ("E484: Can't open file /tmp/vXXXXXX/1").Tested on linux. May need to be tested on OSX and BSD systems.
vicle.vim 1.2.1 2010-10-15 7.0 Jose Figueroa Martinez Fix for OSX reported by Guy Haskin F:
  "It seems like anything greater than about 380 characters fails to send
   corretly."

Changes:
  " You can put this definition in your .vimrc to fix the reported problem in OSX.
  let g:vicle_max_buffer  = 300
vicle.vim 1.2 2010-04-12 7.0 Jose Figueroa Martinez - Removed the size limit for the buffer to send by calling "screen" multiple times.
- Fixed behavior with multiple tabs.
- Tip: It is better to run the interpreter under "rlwrap".
- Limitation: Sending to much text can be slow.
vicle.vim 1.1.3 2009-10-13 7.0 Jose Figueroa Martinez Fixed copying multiple times the same selection when sending a selected text
vicle.vim 1.1.2 2009-10-12 7.0 Jose Figueroa Martinez Fixed cursor return to the last position when sending a command
vicle.vim 1.1.1 2009-10-04 7.0 Jose Figueroa Martinez - Edition Mode are 1 (On) by default.
- Fixed the annoying "Press ENTER ...." that happend when yank send more than 2 lines to Screen.
- More documentation
vicle.vim 1.1 2009-10-02 7.0 Jose Figueroa Martinez - Added a Edition Mode that not clear the Vim screen and send only a custom selection of text. By default, the current line.
- Added the feature for send selected text using the Vim's Visual Mode
- Added more tips to use vicle with more than one language
vicle.vim 1.0.1 2009-02-24 7.0 Jose Figueroa Martinez Fix problem with load/saving history commands, removed some doc, a command for send the content.
The previous version are for Vim7 too. Sorry for the mistake.
vicle.vim 1.0.0 2009-02-23 6.0 Jose Figueroa Martinez Initial upload
ip used for rating: 54.227.160.102

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo