Mercurial > vim
comparison runtime/doc/if_pyth.txt @ 4350:7eaccdaa5304 v7.3.924
updated for version 7.3.924
Problem: Python interface can't easily access options.
Solution: Add vim.options, vim.window.options and vim.buffer.options. (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Mon, 06 May 2013 03:52:55 +0200 |
parents | f1eab4f77a6f |
children | cf1d93a3914a |
comparison
equal
deleted
inserted
replaced
4349:9e3cdd762964 | 4350:7eaccdaa5304 |
---|---|
241 vim.vvars *python-vvars* | 241 vim.vvars *python-vvars* |
242 Dictionary-like objects holding dictionaries with global (|g:|) and | 242 Dictionary-like objects holding dictionaries with global (|g:|) and |
243 vim (|v:|) variables respectively. Identical to `vim.bindeval("g:")`, | 243 vim (|v:|) variables respectively. Identical to `vim.bindeval("g:")`, |
244 but faster. | 244 but faster. |
245 | 245 |
246 vim.options *python-options* | |
247 Object partly supporting mapping protocol (supports setting and | |
248 getting items) providing a read-write access to global options. | |
249 Note: unlike |:set| this provides access only to global options. You | |
250 cannot use this object to obtain or set local options' values or | |
251 access local-only options in any fashion. Raises KeyError if no global | |
252 option with such name exists (i.e. does not raise KeyError for | |
253 |global-local| options and global only options, but does for window- | |
254 and buffer-local ones). Use |python-buffer| objects to access to | |
255 buffer-local options and |python-window| objects to access to | |
256 window-local options. | |
257 | |
246 Output from Python *python-output* | 258 Output from Python *python-output* |
247 Vim displays all Python code output in the Vim message area. Normal | 259 Vim displays all Python code output in the Vim message area. Normal |
248 output appears as information messages, and error output appears as | 260 output appears as information messages, and error output appears as |
249 error messages. | 261 error messages. |
250 | 262 |
280 "b = None" merely updates the variable b, with no effect on the buffer. | 292 "b = None" merely updates the variable b, with no effect on the buffer. |
281 | 293 |
282 Buffer indexes start at zero, as is normal in Python. This differs from vim | 294 Buffer indexes start at zero, as is normal in Python. This differs from vim |
283 line numbers, which start from 1. This is particularly relevant when dealing | 295 line numbers, which start from 1. This is particularly relevant when dealing |
284 with marks (see below) which use vim line numbers. | 296 with marks (see below) which use vim line numbers. |
297 | |
298 The buffer object attributes are: | |
299 b.vars Dictionary-like object used to access | |
300 |buffer-variable|s. | |
301 b.options Mapping object (supports item getting, setting and | |
302 deleting) that provides access to buffer-local options | |
303 and buffer-local values of |global-local| options. Use | |
304 |python-window|.options if option is window-local, | |
305 this object will raise KeyError. If option is | |
306 |global-local| and local value is missing getting it | |
307 will return None. | |
285 | 308 |
286 The buffer object methods are: | 309 The buffer object methods are: |
287 b.append(str) Append a line to the buffer | 310 b.append(str) Append a line to the buffer |
288 b.append(str, nr) Idem, below line "nr" | 311 b.append(str, nr) Idem, below line "nr" |
289 b.append(list) Append a list of lines to the buffer | 312 b.append(list) Append a list of lines to the buffer |
311 :py b.append("bottom") # add a line at the bottom | 334 :py b.append("bottom") # add a line at the bottom |
312 :py n = len(b) # number of lines | 335 :py n = len(b) # number of lines |
313 :py (row,col) = b.mark('a') # named mark | 336 :py (row,col) = b.mark('a') # named mark |
314 :py r = b.range(1,5) # a sub-range of the buffer | 337 :py r = b.range(1,5) # a sub-range of the buffer |
315 :py b.vars["foo"] = "bar" # assign b:foo variable | 338 :py b.vars["foo"] = "bar" # assign b:foo variable |
339 :py b.options["ff"] = "dos" # set fileformat | |
340 :py del b.options["ar"] # same as :set autoread< | |
316 | 341 |
317 ============================================================================== | 342 ============================================================================== |
318 4. Range objects *python-range* | 343 4. Range objects *python-range* |
319 | 344 |
320 Range objects represent a part of a vim buffer. You can obtain them in a | 345 Range objects represent a part of a vim buffer. You can obtain them in a |
361 height (read-write) The window height, in rows | 386 height (read-write) The window height, in rows |
362 width (read-write) The window width, in columns | 387 width (read-write) The window width, in columns |
363 vars (read-only) The window |w:| variables. Attribute is | 388 vars (read-only) The window |w:| variables. Attribute is |
364 unassignable, but you can change window | 389 unassignable, but you can change window |
365 variables this way | 390 variables this way |
391 options (read-only) The window-local options. Attribute is | |
392 unassignable, but you can change window | |
393 options this way. Provides access only to | |
394 window-local options, for buffer-local use | |
395 |python-buffer| and for global ones use | |
396 |python-options|. If option is |global-local| | |
397 and local value is missing getting it will | |
398 return None. | |
366 The height attribute is writable only if the screen is split horizontally. | 399 The height attribute is writable only if the screen is split horizontally. |
367 The width attribute is writable only if the screen is split vertically. | 400 The width attribute is writable only if the screen is split vertically. |
368 | 401 |
369 ============================================================================== | 402 ============================================================================== |
370 6. pyeval() and py3eval() Vim functions *python-pyeval* | 403 6. pyeval() and py3eval() Vim functions *python-pyeval* |