Mercurial > vim
diff runtime/doc/eval.txt @ 12319:c7e95667d14b v8.0.1039
patch 8.0.1039: cannot change a line in not current buffer
commit https://github.com/vim/vim/commit/b31cf2bb0be95d106bd8eef93cc07550591c1d0d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 2 19:45:19 2017 +0200
patch 8.0.1039: cannot change a line in not current buffer
Problem: Cannot change a line in a buffer other than the current one.
Solution: Add setbufline(). (Yasuhiro Matsumoto, Ozaki Kiichi, closes https://github.com/vim/vim/issues/1953)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 02 Sep 2017 20:00:05 +0200 |
parents | 2a8890b80923 |
children | 2779d593a706 |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2316,6 +2316,9 @@ searchpos({pattern} [, {flags} [, {stopl server2client({clientid}, {string}) Number send reply string serverlist() String get a list of available servers +setbufline( {expr}, {lnum}, {line}) + Number set line {lnum} to {line} in buffer + {expr} setbufvar({expr}, {varname}, {val}) none set {varname} in buffer {expr} to {val} setcharsearch({dict}) Dict set character search from {dict} @@ -6858,6 +6861,19 @@ serverlist() *serverlist()* Example: > :echo serverlist() < +setbufline({expr}, {lnum}, {text}) *setbufline()* + Set line {lnum} to {text} in buffer {expr}. To insert + lines use |append()|. + + For the use of {expr}, see |bufname()| above. + + {lnum} is used like with |setline()|. + This works like |setline()| for the specified buffer. + On success 0 is returned, on failure 1 is returned. + + If {expr} is not a valid buffer or {lnum} is not valid, an + error message is given. + setbufvar({expr}, {varname}, {val}) *setbufvar()* Set option or local variable {varname} in buffer {expr} to {val}. @@ -6926,13 +6942,19 @@ setfperm({fname}, {mode}) *setfperm() setline({lnum}, {text}) *setline()* Set line {lnum} of the current buffer to {text}. To insert - lines use |append()|. + lines use |append()|. To set lines in another buffer use + |setbufline()|. + {lnum} is used like with |getline()|. When {lnum} is just below the last line the {text} will be added as a new line. + If this succeeds, 0 is returned. If this fails (most likely - because {lnum} is invalid) 1 is returned. Example: > + because {lnum} is invalid) 1 is returned. + + Example: > :call setline(5, strftime("%c")) + < When {text} is a |List| then line {lnum} and following lines will be set to the items in the list. Example: > :call setline(5, ['aaa', 'bbb', 'ccc'])