Lines Matching refs:vim
10 2. The vim module |lua-vim|
32 :lua local curbuf = vim.buffer() curbuf[7] = "line #7"
54 local linenr = vim.window().line
55 local curline = vim.buffer()[linenr]
105 Lua uses the "vim" module (see |lua-vim|) to issue commands to Vim
112 2. The vim module *lua-vim*
114 Lua interfaces Vim through the "vim" module. The first and last line of the
115 input range are stored in "vim.firstline" and "vim.lastline" respectively. The
119 vim.list([arg]) Returns an empty list or, if "arg" is a Lua
127 :echo luaeval('vim.list(t)')
130 vim.dict([arg]) Returns an empty dictionary or, if "arg" is a
138 :echo luaeval('vim.dict(t)')
142 vim.blob([arg]) Returns an empty blob or, if "arg" is a Lua
147 :echo luaeval('vim.blob(s)')
150 vim.funcref({name}) Returns a Funcref to function {name} (see
154 vim.buffer([arg]) If "arg" is a number, returns buffer with
163 vim.window([arg]) If "arg" is a number, returns window with
169 vim.type({arg}) Returns the type of {arg}. It is equivalent to
174 :lua l = vim.list()
175 :lua print(type(l), vim.type(l))
178 vim.command({cmds}) Executes one or more lines of Ex-mode commands
181 :lua vim.command"set tw=60"
182 :lua vim.command"normal ddp"
184 vim.command([[
190 vim.eval({expr}) Evaluates expression {expr} (see |expression|),
197 :lua tw = vim.eval"&tw"
198 :lua print(vim.eval"{'a': 'one'}".a)
200 vim.line() Returns the current line (without the trailing
203 vim.beep() Beeps.
205 vim.open({fname}) Opens a new buffer for file {fname} and
209 vim.call({name} [, {args}])
212 :lua print(vim.call('has', 'timers'))
214 vim.fn Proxy to call Vim functions. Proxy methods are
216 :lua print(vim.fn.has('timers'))
218 vim.lua_version The Lua version Vim was compiled with, in the
221 vim.version() Returns a Lua table with the Vim version.
227 *lua-vim-variables*
229 from Lua conveniently and idiomatically by referencing the `vim.*` Lua tables
235 vim.g.foo = 5 -- Set the g:foo Vim script variable.
236 print(vim.g.foo) -- Get and print the g:foo Vim script variable.
237 vim.g.foo = nil -- Delete (:unlet) the Vim script variable.
239 vim.g *vim.g*
243 vim.b *vim.b*
247 vim.w *vim.w*
251 vim.t *vim.t*
255 vim.v *vim.v*
262 List userdata represent vim lists, and the interface tries to follow closely
298 :lua l = vim.eval('l') -- same 'l'
299 :lua l:add(vim.list())
314 Similarly to list userdata, dict userdata represent vim dictionaries; since
331 :lua d = vim.eval('d') -- same 'd'
343 Blob userdata represent vim blobs. A blob "b" has the following properties:
359 :lua b = vim.eval('b') -- same 'b'
386 :lua i1 = vim.funcref('I')
387 :lua i2 = vim.eval('R')
394 :lua d = vim.eval('mydict'); d.len = vim.funcref('Mylen')
403 vim.fn.timer_start(1000, function(timer)
411 Buffer userdata represent vim buffers. A buffer userdata "b" has the following
439 :lua b = vim.buffer() -- current buffer
445 :3,4lua for i=vim.lastline,vim.firstline,-1 do b[i] = nil end
446 :lua vim.open"myfile"() -- open buffer and set it as current
450 local b = vim.buffer(true) -- first buffer in list
455 vim.beep()
463 Window objects represent vim windows. A window userdata "w" has the following
484 :lua w = vim.window() -- current window
488 :lua n,w = 0,vim.window(true) while w~=nil do n,w = n + 1,w:next() end
495 The (dual) equivalent of "vim.eval" for passing Lua values to Vim is
514 :lua a = vim.list():add('newlist')
550 vim:tw=78:ts=8:noet:ft=help:norl: