1 *if_mzsch.txt* For Vim version 7.2. Last change: 2009 Jun 24
4 VIM REFERENCE MANUAL by Sergey Khorev
7 The MzScheme Interface to Vim *mzscheme* *MzScheme*
9 1. Commands |mzscheme-commands|
10 2. Examples |mzscheme-examples|
11 3. Threads |mzscheme-threads|
12 4. The Vim access procedures |mzscheme-vim|
13 5. Dynamic loading |mzscheme-dynamic|
15 {Vi does not have any of these commands}
17 The MzScheme interface is available only if Vim was compiled with the
20 Based on the work of Brent Fulgham.
21 Dynamic loading added by Sergey Khorev
23 For downloading MzScheme and other info:
24 http://www.plt-scheme.org/software/mzscheme/
26 Note: On FreeBSD you should use the "drscheme" port.
28 ==============================================================================
29 1. Commands *mzscheme-commands*
32 :[range]mz[scheme] {stmt}
33 Execute MzScheme statement {stmt}. {not in Vi}
35 :[range]mz[scheme] << {endmarker}
38 Execute inlined MzScheme script {script}.
39 Note: This command doesn't work if the MzScheme
40 feature wasn't compiled in. To avoid errors, see
44 :[range]mzf[ile] {file} Execute the MzScheme script in {file}. {not in Vi}
46 All of these commands do essentially the same thing - they execute a piece of
47 MzScheme code, with the "current range" set to the given line
50 In the case of :mzscheme, the code to execute is in the command-line.
51 In the case of :mzfile, the code to execute is the contents of the given file.
53 MzScheme interface defines exception exn:vim, derived from exn.
54 It is raised for various Vim errors.
56 During compilation, the MzScheme interface will remember the current MzScheme
57 collection path. If you want to specify additional paths use the
58 'current-library-collection-paths' parameter. E.g., to cons the user-local
59 MzScheme collection path: >
61 (current-library-collection-paths
63 (build-path (find-system-path 'addon-dir) (version) "collects")
64 (current-library-collection-paths)))
68 All functionality is provided through module vimext.
70 The exn:vim is available without explicit import.
72 To avoid clashes with MzScheme, consider using prefix when requiring module,
74 :mzscheme (require (prefix vim- vimext))
76 All the examples below assume this naming scheme.
79 When executed in the |sandbox|, access to some filesystem and Vim interface
80 procedures is restricted.
82 ==============================================================================
83 2. Examples *mzscheme-examples*
85 :mzscheme (display "Hello")
86 :mz (display (string-append "Using MzScheme version " (version)))
87 :mzscheme (require (prefix vim- vimext)) ; for MzScheme < 4.x
88 :mzscheme (require (prefix-in vim- 'vimext)) ; MzScheme 4.x
89 :mzscheme (vim-set-buff-line 10 "This is line #10")
91 Inline script usage: >
92 function! <SID>SetFirstLine()
95 (require (prefix vim- vimext))
96 ; for newer versions (require (prefix-in vim- 'vimext))
97 (vim-set-buff-line 1 "This is line #1")
102 nmap <F9> :call <SID>SetFirstLine() <CR>
105 :mzfile supascript.scm
107 Vim exception handling: >
109 (require (prefix vim- vimext))
110 ; for newer versions (require (prefix-in vim- 'vimext))
112 ([exn:vim? (lambda (e) (display (exn-message e)))])
113 (vim-eval "nonsense-string"))
116 Auto-instantiation of vimext module (can be placed in your |vimrc|): >
117 function! MzRequire()
118 :redir => l:mzversion
121 if strpart(l:mzversion, 1, 1) < "4"
122 " MzScheme versions < 4.x:
123 :mz (require (prefix vim- vimext))
126 :mz (require (prefix-in vim- 'vimext))
131 silent call MzRequire()
134 ==============================================================================
135 3. Threads *mzscheme-threads*
137 The MzScheme interface supports threads. They are independent from OS threads,
138 thus scheduling is required. The option 'mzquantum' determines how often
139 Vim should poll for available MzScheme threads.
141 Thread scheduling in the console version of Vim is less reliable than in the
144 ==============================================================================
145 5. VIM Functions *mzscheme-vim*
148 The 'vimext' module provides access to procedures defined in the MzScheme
153 (command {command-string}) Perform the vim ":Ex" style command.
154 (eval {expr-string}) Evaluate the vim expression into
155 respective MzScheme object: |Lists| are
156 represented as Scheme lists,
157 |Dictionaries| as hash tables.
158 NOTE the name clashes with MzScheme eval
159 (range-start) Start/End of the range passed with
160 (range-end) the Scheme command.
162 (get-option {option-name} [buffer-or-window]) Get Vim option value (either
163 local or global, see set-option).
164 (set-option {string} [buffer-or-window])
165 Set a Vim option. String must have option
166 setting form (like optname=optval, or
167 optname+=optval, etc.) When called with
168 {buffer} or {window} the local option will
169 be set. The symbol 'global can be passed
170 as {buffer-or-window}. Then |:setglobal|
173 Buffers *mzscheme-buffer*
175 (buff? {object}) Is object a buffer?
176 (buff-valid? {object}) Is object a valid buffer? (i.e.
177 corresponds to the real Vim buffer)
178 (get-buff-line {linenr} [buffer])
179 Get line from a buffer.
180 (set-buff-line {linenr} {string} [buffer])
181 Set a line in a buffer. If {string} is #f,
182 the line gets deleted. The [buffer]
183 argument is optional. If omitted, the
184 current buffer will be used.
185 (get-buff-line-list {start} {end} [buffer])
186 Get a list of lines in a buffer. {Start}
187 and {end} are 1-based. {Start} is
188 inclusive, {end} - exclusive.
189 (set-buff-line-list {start} {end} {string-list} [buffer])
190 Set a list of lines in a buffer. If
191 string-list is #f or null, the lines get
192 deleted. If a list is shorter than
193 {end}-{start} the remaining lines will
195 (get-buff-name [buffer]) Get a buffer's text name.
196 (get-buff-num [buffer]) Get a buffer's number.
197 (get-buff-size [buffer]) Get buffer line count.
198 (insert-buff-line-list {linenr} {string/string-list} [buffer])
199 Insert a list of lines into a buffer after
200 {linenr}. If {linenr} is 0, lines will be
202 (curr-buff) Get the current buffer. Use procedures
203 from "vimcmd" module to change it.
204 (buff-count) Get count of total buffers in the editor.
205 (get-next-buff [buffer]) Get next buffer.
206 (get-prev-buff [buffer]) Get previous buffer. Return #f when there
208 (open-buff {filename}) Open a new buffer (for file "name")
209 (get-buff-by-name {buffername}) Get a buffer by its filename or #f
210 if there is no such buffer.
211 (get-buff-by-num {buffernum}) Get a buffer by its number (return #f if
212 there is no buffer with this number).
214 Windows *mzscheme-window*
216 (win? {object}) Is object a window?
217 (win-valid? {object}) Is object a valid window (i.e. corresponds
218 to the real Vim window)?
219 (curr-win) Get the current window.
220 (win-count) Get count of windows.
221 (get-win-num [window]) Get window number.
222 (get-win-by-num {windownum}) Get window by its number.
223 (get-win-buffer [window]) Get the buffer for a given window.
224 (get-win-height [window])
225 (set-win-height {height} [window]) Get/Set height of window.
226 (get-win-width [window])
227 (set-win-width {width} [window])Get/Set width of window.
228 (get-win-list [buffer]) Get list of windows for a buffer.
229 (get-cursor [window]) Get cursor position in a window as
230 a pair (linenr . column).
231 (set-cursor (line . col) [window]) Set cursor position.
233 ==============================================================================
234 5. Dynamic loading *mzscheme-dynamic* *E815*
236 On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
237 output then includes |+mzscheme/dyn|.
239 This means that Vim will search for the MzScheme DLL files only when needed.
240 When you don't use the MzScheme interface you don't need them, thus you can
241 use Vim without these DLL files.
243 To use the MzScheme interface the MzScheme DLLs must be in your search path.
244 In a console window type "path" to see what directories are used.
246 The names of the DLLs must match the MzScheme version Vim was compiled with.
247 For MzScheme version 209 they will be "libmzsch209_000.dll" and
248 "libmzgc209_000.dll". To know for sure look at the output of the ":version"
249 command, look for -DDYNAMIC_MZSCH_DLL="something" and
250 -DDYNAMIC_MZGC_DLL="something" in the "Compilation" info.
252 ======================================================================
253 vim:tw=78:ts=8:sts=4:ft=help:norl: