diff options
author | Akshay <[email protected]> | 2023-02-12 06:43:49 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2023-02-12 06:43:49 +0000 |
commit | 366df8852f503523cc4f9046d82ba9a99dd51d7f (patch) | |
tree | 635884dd5700cdc2a22a8885031aa67816bbe1b0 /docs/posts/hold_position!/index.html | |
parent | 57a1fc656e05e1fcf07e4cff3dc988c6b5c2bc59 (diff) |
new art: lapse
Diffstat (limited to 'docs/posts/hold_position!/index.html')
-rw-r--r-- | docs/posts/hold_position!/index.html | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/docs/posts/hold_position!/index.html b/docs/posts/hold_position!/index.html index ec63508..68955fe 100644 --- a/docs/posts/hold_position!/index.html +++ b/docs/posts/hold_position!/index.html | |||
@@ -28,7 +28,7 @@ | |||
28 | 30/07 — 2019 | 28 | 30/07 — 2019 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 9.18 | 31 | 9.19 |
32 | </span> | 32 | </span> |
33 | <span class="stats-unit">cm</span> | 33 | <span class="stats-unit">cm</span> |
34 |   | 34 |   |
@@ -42,14 +42,24 @@ | |||
42 | Hold Position! | 42 | Hold Position! |
43 | </h1> | 43 | </h1> |
44 | <div class="post-text"> | 44 | <div class="post-text"> |
45 | <p>Often times, when I run a vim command that makes “big” changes to a file (a macro or a <code>:vimgrep</code> command) I lose my original position and feel disoriented.</p> | 45 | <p>Often times, when I run a vim command that makes “big” changes to a |
46 | file (a macro or a <code>:vimgrep</code> command) I lose my original | ||
47 | position and feel disoriented.</p> | ||
46 | <p><em>Save position with <code>winsaveview()</code>!</em></p> | 48 | <p><em>Save position with <code>winsaveview()</code>!</em></p> |
47 | <p>The <code>winsaveview()</code> command returns a <code>Dictionary</code> that contains information about the view of the current window. This includes the cursor line number, cursor coloumn, the top most line in the window and a couple of other values, none of which concern us.</p> | 49 | <p>The <code>winsaveview()</code> command returns a |
48 | <p>Before running our command (one that jumps around the buffer, a lot), we save our view, and restore it once its done, with <code>winrestview</code>.</p> | 50 | <code>Dictionary</code> that contains information about the view of the |
51 | current window. This includes the cursor line number, cursor coloumn, | ||
52 | the top most line in the window and a couple of other values, none of | ||
53 | which concern us.</p> | ||
54 | <p>Before running our command (one that jumps around the buffer, a lot), | ||
55 | we save our view, and restore it once its done, with | ||
56 | <code>winrestview</code>.</p> | ||
49 | <pre><code>let view = winsaveview() | 57 | <pre><code>let view = winsaveview() |
50 | s/\s\+$//gc " find and (confirm) replace trailing blanks | 58 | s/\s\+$//gc " find and (confirm) replace trailing blanks |
51 | winrestview(view) " restore our original view!</code></pre> | 59 | winrestview(view) " restore our original view!</code></pre> |
52 | <p>It might seem a little overkill in the above example, just use `` (double backticks) instead, but it comes in handy when you run your file through heavier filtering.</p> | 60 | <p>It might seem a little overkill in the above example, just use `` |
61 | (double backticks) instead, but it comes in handy when you run your file | ||
62 | through heavier filtering.</p> | ||
53 | 63 | ||
54 | </div> | 64 | </div> |
55 | 65 | ||