aboutsummaryrefslogtreecommitdiff
path: root/docs/posts/hold_position!/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/posts/hold_position!/index.html')
-rw-r--r--docs/posts/hold_position!/index.html20
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 &nbsp 34 &nbsp
@@ -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
46file (a macro or a <code>:vimgrep</code> command) I lose my original
47position 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
51current window. This includes the cursor line number, cursor coloumn,
52the top most line in the window and a couple of other values, none of
53which concern us.</p>
54<p>Before running our command (one that jumps around the buffer, a lot),
55we 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()
50s/\s\+$//gc &quot; find and (confirm) replace trailing blanks 58s/\s\+$//gc &quot; find and (confirm) replace trailing blanks
51winrestview(view) &quot; restore our original view!</code></pre> 59winrestview(view) &quot; 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
62through heavier filtering.</p>
53 63
54 </div> 64 </div>
55 65