diff options
Diffstat (limited to 'docs/posts/hold_position!')
-rw-r--r-- | docs/posts/hold_position!/index.html | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/docs/posts/hold_position!/index.html b/docs/posts/hold_position!/index.html index 58851c5..b14d41a 100644 --- a/docs/posts/hold_position!/index.html +++ b/docs/posts/hold_position!/index.html | |||
@@ -37,27 +37,36 @@ | |||
37 | Hold Position! | 37 | Hold Position! |
38 | </h1> | 38 | </h1> |
39 | <div class="post-text"> | 39 | <div class="post-text"> |
40 | <p>Often times, when I run a vim command that makes “big” changes to a file (a | 40 | <!DOCTYPE html> |
41 | macro or a <code>:vimgrep</code> command) I lose my original position and feel disoriented.</p> | 41 | <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> |
42 | 42 | <head> | |
43 | <meta charset="utf-8" /> | ||
44 | <meta name="generator" content="pandoc" /> | ||
45 | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> | ||
46 | <title>hold_position!</title> | ||
47 | <style> | ||
48 | code{white-space: pre-wrap;} | ||
49 | span.smallcaps{font-variant: small-caps;} | ||
50 | span.underline{text-decoration: underline;} | ||
51 | div.column{display: inline-block; vertical-align: top; width: 50%;} | ||
52 | div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} | ||
53 | ul.task-list{list-style: none;} | ||
54 | </style> | ||
55 | <!--[if lt IE 9]> | ||
56 | <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> | ||
57 | <![endif]--> | ||
58 | </head> | ||
59 | <body> | ||
60 | <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> | ||
43 | <p><em>Save position with <code>winsaveview()</code>!</em></p> | 61 | <p><em>Save position with <code>winsaveview()</code>!</em></p> |
44 | 62 | <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> | |
45 | <p>The <code>winsaveview()</code> command returns a <code>Dictionary</code> that contains information | 63 | <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> |
46 | about the view of the current window. This includes the cursor line number, | ||
47 | cursor coloumn, the top most line in the window and a couple of other values, | ||
48 | none of which concern us.</p> | ||
49 | |||
50 | <p>Before running our command (one that jumps around the buffer, a lot), we save | ||
51 | our view, and restore it once its done, with <code>winrestview</code>.</p> | ||
52 | |||
53 | <pre><code>let view = winsaveview() | 64 | <pre><code>let view = winsaveview() |
54 | s/\s\+$//gc " find and (confirm) replace trailing blanks | 65 | s/\s\+$//gc " find and (confirm) replace trailing blanks |
55 | winrestview(view) " restore our original view! | 66 | winrestview(view) " restore our original view!</code></pre> |
56 | </code></pre> | 67 | <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> |
57 | 68 | </body> | |
58 | <p>It might seem a little overkill in the above example, just use `` (double | 69 | </html> |
59 | backticks) instead, but it comes in handy when you run your file through | ||
60 | heavier filtering.</p> | ||
61 | 70 | ||
62 | </div> | 71 | </div> |
63 | 72 | ||