Mercurial > vim
comparison runtime/doc/usr_50.txt @ 29269:0fdf36de4018
Update runtime files
Commit: https://github.com/vim/vim/commit/8cc5b559f70041361612b8a6a87922503b33baa6
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 23 13:04:20 2022 +0100
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 23 Jun 2022 14:15:04 +0200 |
parents | c58baa6d6dda |
children | dc4de65a7fb7 |
comparison
equal
deleted
inserted
replaced
29268:4b53fd331519 | 29269:0fdf36de4018 |
---|---|
1 *usr_50.txt* For Vim version 8.2. Last change: 2022 Jun 03 | 1 *usr_50.txt* For Vim version 8.2. Last change: 2022 Jun 20 |
2 | 2 |
3 VIM USER MANUAL - by Bram Moolenaar | 3 VIM USER MANUAL - by Bram Moolenaar |
4 | 4 |
5 Advanced Vim script writing | 5 Advanced Vim script writing |
6 | 6 |
114 we'll explain that further down. | 114 we'll explain that further down. |
115 | 115 |
116 ============================================================================== | 116 ============================================================================== |
117 *50.3* Restoring the view | 117 *50.3* Restoring the view |
118 | 118 |
119 Sometimes you want to make a change and go back to where the cursor was. | 119 Sometimes you want to jump around, make a change and then go back to the same |
120 Restoring the relative position would also be nice, so that the same line | 120 position and view. For example to change something in the file header. This |
121 appears at the top of the window. | 121 can be done with two functions: > |
122 | 122 |
123 This example yanks the current line, puts it above the first line in the file | 123 var view = winsaveview() |
124 and then restores the view: > | 124 # Move around, make changes |
125 | 125 winrestview(view) |
126 map ,p ma"aYHmbgg"aP`bzt`a | |
127 | |
128 What this does: > | |
129 ma"aYHmbgg"aP`bzt`a | |
130 < ma set mark a at cursor position | |
131 "aY yank current line into register a | |
132 Hmb go to top line in window and set mark b there | |
133 gg go to first line in file | |
134 "aP put the yanked line above it | |
135 `b go back to top line in display | |
136 zt position the text in the window as before | |
137 `a go back to saved cursor position | |
138 | |
139 | 126 |
140 ============================================================================== | 127 ============================================================================== |
141 | 128 |
142 Next chapter: |usr_51.txt| Create a plugin | 129 Next chapter: |usr_51.txt| Create a plugin |
143 | 130 |