aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/builtin.txt41
-rw-r--r--runtime/doc/lua.txt17
-rw-r--r--runtime/doc/news.txt1
-rw-r--r--runtime/lua/vim/_editor.lua14
4 files changed, 61 insertions, 12 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 91531db656..d5607afdf5 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -546,7 +546,8 @@ undotree() List undo file tree
uniq({list} [, {func} [, {dict}]])
List remove adjacent duplicates from a list
values({dict}) List values in {dict}
-virtcol({expr}) Number screen column of cursor or mark
+virtcol({expr} [, {list}]) Number or List
+ screen column of cursor or mark
virtcol2col({winid}, {lnum}, {col})
Number byte index of a character on screen
visualmode([expr]) String last visual mode used
@@ -637,6 +638,7 @@ add({object}, {expr}) *add()*
and({expr}, {expr}) *and()*
Bitwise AND on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
+ Also see `or()` and `xor()`.
Example: >
:let flag = and(bits, 0x80)
< Can also be used as a |method|: >
@@ -2525,7 +2527,7 @@ funcref({name} [, {arglist}] [, {dict}])
Can also be used as a |method|: >
GetFuncname()->funcref([arg])
<
- *function()* *partial* *E700* *E922* *E923*
+ *function()* *partial* *E700* *E923*
function({name} [, {arglist}] [, {dict}])
Return a |Funcref| variable that refers to function {name}.
{name} can be the name of a user defined function or an
@@ -9070,7 +9072,7 @@ values({dict}) *values()*
Can also be used as a |method|: >
mydict->values()
-virtcol({expr}) *virtcol()*
+virtcol({expr} [, {list}]) *virtcol()*
The result is a Number, which is the screen column of the file
position given with {expr}. That is, the last screen position
occupied by the character at that position, when the screen
@@ -9079,13 +9081,17 @@ virtcol({expr}) *virtcol()*
the <Tab>. For example, for a <Tab> in column 1, with 'ts'
set to 8, it returns 8. |conceal| is ignored.
For the byte position use |col()|.
+
For the use of {expr} see |col()|.
- When 'virtualedit' is used {expr} can be [lnum, col, off], where
- "off" is the offset in screen columns from the start of the
- character. E.g., a position within a <Tab> or after the last
- character. When "off" is omitted zero is used.
- When Virtual editing is active in the current mode, a position
- beyond the end of the line can be returned. |'virtualedit'|
+
+ When 'virtualedit' is used {expr} can be [lnum, col, off],
+ where "off" is the offset in screen columns from the start of
+ the character. E.g., a position within a <Tab> or after the
+ last character. When "off" is omitted zero is used. When
+ Virtual editing is active in the current mode, a position
+ beyond the end of the line can be returned. Also see
+ |'virtualedit'|
+
The accepted positions are:
. the cursor position
$ the end of the cursor line (the result is the
@@ -9097,11 +9103,22 @@ virtcol({expr}) *virtcol()*
cursor is the end). When not in Visual mode
returns the cursor position. Differs from |'<| in
that it's updated right away.
+
+ If {list} is present and non-zero then virtcol() returns a List
+ with the first and last screen position occupied by the
+ character.
+
Note that only marks in the current file can be used.
Examples: >
- virtcol(".") with text "foo^Lbar", with cursor on the "^L", returns 5
- virtcol("$") with text "foo^Lbar", returns 9
- virtcol("'t") with text " there", with 't at 'h', returns 6
+ " With text "foo^Lbar" and cursor on the "^L":
+
+ virtcol(".") " returns 5
+ virtcol(".", 1) " returns [4, 5]
+ virtcol("$") " returns 9
+
+ " With text " there", with 't at 'h':
+
+ virtcol("'t") " returns 6
< The first column is 1. 0 is returned for an error.
A more advanced example that echoes the maximum length of
all lines: >
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 2d3ea75588..9d4272c906 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1404,6 +1404,23 @@ inspect({object}, {options}) *vim.inspect()*
• https://github.com/kikito/inspect.lua
• https://github.com/mpeterv/vinspect
+keycode({str}) *vim.keycode()*
+ Translate keycodes.
+
+ Example: >lua
+ local k = vim.keycode
+ vim.g.mapleader = k'<bs>'
+<
+
+ Parameters: ~
+ • {str} string String to be converted.
+
+ Return: ~
+ string
+
+ See also: ~
+ • |nvim_replace_termcodes()|
+
lua_omnifunc({find_start}, {_}) *vim.lua_omnifunc()*
Omnifunc for completing lua values from from the runtime lua interpreter,
similar to the builtin completion for the `:lua` command.
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 3f07dd2e66..2a776ea30a 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -37,6 +37,7 @@ The following new APIs or features were added.
• |vim.iter()| provides a generic iterator interface for tables and Lua
iterators |luaref-in|.
+• Added |vim.keycode()| for translating keycodes in a string.
==============================================================================
CHANGED FEATURES *news-changed*
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index c922ec93db..20e813d77c 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -829,6 +829,20 @@ function vim.print(...)
return ...
end
+--- Translate keycodes.
+---
+--- Example:
+--- <pre>lua
+--- local k = vim.keycode
+--- vim.g.mapleader = k'<bs>'
+--- </pre>
+--- @param str string String to be converted.
+--- @return string
+--- @see |nvim_replace_termcodes()|
+function vim.keycode(str)
+ return vim.api.nvim_replace_termcodes(str, true, true, true)
+end
+
function vim._cs_remote(rcid, server_addr, connect_error, args)
local function connection_failure_errmsg(consequence)
local explanation