summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-07 18:16:36 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-07 18:16:36 +0200
commitbb861e293e0170455184079fa537278754b07911 (patch)
treed5f14938d1ebbf6cde67bdf6d2e26a6391106d32 /runtime
parentc82dd86084581afa5113b0dd9ade7a631b89b4fc (diff)
patch 8.2.0924: cannot save and restore a register properlyv8.2.0924
Problem: Cannot save and restore a register properly. Solution: Add getreginfo() and make setreg() accept a dictionary. (Andy Massimino, closes #3370)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt38
-rw-r--r--runtime/doc/usr_41.txt1
2 files changed, 35 insertions, 4 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 66246e6347..52994f1179 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2506,8 +2506,9 @@ getpid() Number process ID of Vim
getpos({expr}) List position of cursor, mark, etc.
getqflist([{what}]) List list of quickfix items
getreg([{regname} [, 1 [, {list}]]])
- String or List contents of register
-getregtype([{regname}]) String type of register
+ String or List contents of a register
+getreginfo([{regname}]) Dict information about a register
+getregtype([{regname}]) String type of a register
gettabinfo([{expr}]) List list of tab pages
gettabvar({nr}, {varname} [, {def}])
any variable {varname} in tab {nr} or {def}
@@ -5596,6 +5597,31 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()*
Can also be used as a |method|: >
GetRegname()->getreg()
+getreginfo([{regname}]) *getreginfo()*
+ Returns detailed information about register {regname} as a
+ Dictionary with the following entries:
+ regcontents List of lines contained in register
+ {regname}, like
+ |getreg|({regname}, 1, 1).
+ regtype the type of register {regname}, as in
+ |getregtype()|.
+ isunnamed Boolean flag, v:true if this register
+ is currently pointed to by the unnamed
+ register.
+ points_to for the unnamed register, gives the
+ single letter name of the register
+ currently pointed to (see |quotequote|).
+ For example, after deleting a line
+ with `dd`, this field will be "1",
+ which is the register that got the
+ deleted text.
+
+ If {regname} is invalid or not set, an empty Dictionary
+ will be returned.
+ If {regname} is not specified, |v:register| is used.
+
+ Can also be used as a |method|: >
+ GetRegname()->getreginfo()
getregtype([{regname}]) *getregtype()*
The result is a String, which is type of register {regname}.
@@ -9090,8 +9116,8 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()*
setreg({regname}, {value} [, {options}])
Set the register {regname} to {value}.
If {regname} is "" or "@", the unnamed register '"' is used.
- {value} may be any value returned by |getreg()|, including
- a |List|.
+ {value} may be any value returned by |getreg()| or
+ |getreginfo()|, including a |List| or |Dict|.
If {options} contains "a" or {regname} is upper case,
then the value is appended.
{options} can also contain a register type specification:
@@ -9118,9 +9144,13 @@ setreg({regname}, {value} [, {options}])
:call setreg(v:register, @*)
:call setreg('*', @%, 'ac')
:call setreg('a', "1\n2\n3", 'b5')
+ :call setreg('"', { 'points_to': 'a'})
< This example shows using the functions to save and restore a
register: >
+ :let var_a = getreginfo()
+ :call setreg('a', var_a)
+< or:
:let var_a = getreg('a', 1, 1)
:let var_amode = getregtype('a')
....
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 89d25dfdcb..1d896f9a98 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1155,6 +1155,7 @@ Various: *various-functions*
undotree() return the state of the undo tree
getreg() get contents of a register
+ getreginfo() get information about a register
getregtype() get type of a register
setreg() set contents and type of a register
reg_executing() return the name of the register being executed