1
- *usr_50.txt* For Vim version 9.0. Last change: 2022 Jun 03
1
+ *usr_50.txt* For Vim version 9.0. Last change: 2022 Jun 20
2
2
3
3
VIM USER MANUAL - by Bram Moolenaar
4
4
5
5
Advanced Vim script writing
6
6
7
7
8
8
| 50.1 | Exceptions
9
- | 50.2 | Function with variable number of arguments
9
+ | 50.2 | Function with variable number of arguments
10
10
| 50.3 | Restoring the view
11
11
12
12
Next chapter: | usr_51.txt | Create a plugin
@@ -104,7 +104,7 @@ You can call it like this: >
104
104
105
105
Show('Title', 'one', 'two', 'three')
106
106
< start is Title Arg 0 is one Arg 1 is two Arg 2 is three ~
107
-
107
+
108
108
This uses the `echohl ` command to specify the highlighting used for the
109
109
following `echo ` command. `echohl None` stops it again. The `echon ` command
110
110
works like `echo ` , but doesn't output a line break.
@@ -116,26 +116,13 @@ we'll explain that further down.
116
116
==============================================================================
117
117
*50.3* Restoring the view
118
118
119
- Sometimes you want to make a change and go back to where the cursor was.
120
- Restoring the relative position would also be nice, so that the same line
121
- appears at the top of the window.
122
-
123
- This example yanks the current line, puts it above the first line in the file
124
- and then restores the view: >
125
-
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
119
+ Sometimes you want to jump around, make a change and then go back to the same
120
+ position and view. For example to change something in the file header. This
121
+ can be done with two functions: >
138
122
123
+ var view = winsaveview()
124
+ # Move around, make changes
125
+ winrestview(view)
139
126
140
127
==============================================================================
141
128
0 commit comments