diff runtime/doc/usr_50.txt @ 29066:f8e9d5023bf6

Update runtime files Commit: https://github.com/vim/vim/commit/cfa8f9a3f285060152ebbdbf86fbc7aecf1dd756 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jun 3 21:59:47 2022 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Fri, 03 Jun 2022 23:00:05 +0200
parents 82244cfc4694
children f3ec3c57e070
line wrap: on
line diff
--- a/runtime/doc/usr_50.txt
+++ b/runtime/doc/usr_50.txt
@@ -1,22 +1,71 @@
-*usr_50.txt*	For Vim version 8.2.  Last change: 2022 May 13
+*usr_50.txt*	For Vim version 8.2.  Last change: 2022 Jun 03
 
 		     VIM USER MANUAL - by Bram Moolenaar
 
 			 Advanced Vim script writing
 
 
-TODO - this chapter is to be written
-
-|50.1|	Writing stuff
+|50.1|	Line continuation
+|50.2|	Restoring the view
 
      Next chapter: |usr_51.txt|  Create a plugin
  Previous chapter: |usr_45.txt|  Select your language (local)
 Table of contents: |usr_toc.txt|
 
 ==============================================================================
-*50.1*	Writing stuff
+*50.1*	Line continuation
+
+In legacy Vim script line contination is done by preceding a contination line
+with a backslash: >
+	let mylist = [
+			\ 'one',
+			\ 'two',
+			\ ]
+
+This requires the 'cpo' option to exclude the "C" flag.  Normally this is done
+by putting this at the start of the script: >
+	let s:save_cpo = &cpo
+	set cpo&vim
+
+And restore the option at the end of the script: >
+	let &cpo = s:save_cpo
+	unlet s:save_cpo
+
+A few more details can be found here: |line-continuation|.
+
+In |Vim9| script the backslash can still be used, but in most places it is not
+needed: >
+	var mylist = [
+			'one',
+			'two',
+			]
 
-TODO
+Also, the 'cpo' option does not need to be changed.  See
+|vim9-line-continuation| for details.
+
+==============================================================================
+*50.2*	Restoring the view
+
+Sometimes you want to make a change and go back to where the cursor was.
+Restoring the relative position would also be nice, so that the same line
+appears at the top of the window.
+
+This example yanks the current line, puts it above the first line in the file
+and then restores the view: >
+
+	map ,p ma"aYHmbgg"aP`bzt`a
+
+What this does: >
+	ma"aYHmbgg"aP`bzt`a
+<	ma			set mark a at cursor position
+	  "aY			yank current line into register a
+	     Hmb		go to top line in window and set mark b there
+		gg		go to first line in file
+		  "aP		put the yanked line above it
+		     `b		go back to top line in display
+		       zt	position the text in the window as before
+			 `a	go back to saved cursor position
+
 
 ==============================================================================