From a3a9f86d4a11029542a94b00044b5a181a68c9cd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 28 Feb 2025 13:40:26 +0800 Subject: vim-patch:8.2.4594: need to write script to a file to be able to source them Problem: Need to write script to a file to be able to source them. Solution: Make ":source" use lines from the current buffer. (Yegappan Lakshmanan et al., closes vim/vim#9967) https://github.com/vim/vim/commit/36a5b6867bb6c0bd69c8da7d788000ab8a0b0ab0 Most code and test changes are reverted or modified again in patch 8.2.4603, so only port parts that are untouched in patch 8.2.4603. Co-authored-by: Yegappan Lakshmanan --- runtime/doc/repeat.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index e65caa72ed..4c95066998 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -192,14 +192,19 @@ Using Vim scripts *using-scripts* For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. *:so* *:source* *load-vim-script* -:[range]so[urce] [file] Runs |Ex-commands| or Lua code (".lua" files) from - [file]. - If no [file], the current buffer is used and treated - as Lua code if 'filetype' is "lua" or its filename - ends with ".lua". +:so[urce] {file} Runs |Ex-commands| or Lua code (".lua" files) from + {file}. Triggers the |SourcePre| autocommand. + +:[range]so[urce] Read Ex commands or Lua code from the [range] of lines + in the current buffer. The buffer is treated as Lua + code if 'filetype' is "lua" or its filename ends with + ".lua". When sourcing commands or Lua code from the + current buffer, the same script-ID || is used + even if the buffer is sourced multiple times. + *:source!* -:[range]so[urce]! {file} +:so[urce]! {file} Runs |Normal-mode| commands from {file}. When used after |:global|, |:argdo|, |:windo|, |:bufdo|, in a loop or when another command follows the display -- cgit