aboutsummaryrefslogtreecommitdiff
path: root/docs/posts/hold_position!
diff options
context:
space:
mode:
Diffstat (limited to 'docs/posts/hold_position!')
-rw-r--r--docs/posts/hold_position!/index.html57
1 files changed, 57 insertions, 0 deletions
diff --git a/docs/posts/hold_position!/index.html b/docs/posts/hold_position!/index.html
new file mode 100644
index 0000000..8d441cf
--- /dev/null
+++ b/docs/posts/hold_position!/index.html
@@ -0,0 +1,57 @@
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <link rel="stylesheet" href="/style.css">
5 <meta charset="UTF-8">
6 <meta name="viewport" content="initial-scale=1">
7 <meta content="#ffffff" name="theme-color">
8 <meta name="HandheldFriendly" content="true">
9 <meta property="og:title" content="nerdypepper">
10 <meta property="og:type" content="website">
11 <meta property="og:description" content="a static site {for, by, about} me ">
12 <meta property="og:url" content="https://nerdypepper.tech">
13 <body>
14 <div class="posts">
15 <div class="post">
16 <div class="date">
17 30/07 2019
18 <span class="commit-hash">
19 <a href="https://github.com/nerdypepper/site/blob/master/posts/hold_position!.md
20" style="text-decoration: none">
21 487b33f
22 </a>
23 </span>
24 </div>
25 <span class="post-title">
26 Hold Position!
27 </span>
28 <div class="post-text">
29 <p>Often times, when I run a vim command that makes &#8220;big&#8221; changes to a file (a
30macro or a <code>:vimgrep</code> command) I lose my original position and feel disoriented.</p>
31
32<p><em>Save position with <code>winsaveview()</code>!</em></p>
33
34<p>The <code>winsaveview()</code> command returns a <code>Dictionary</code> that contains information
35about the view of the current window. This includes the cursor line number,
36cursor coloumn, the top most line in the window and a couple of other values,
37none of which concern us.</p>
38
39<p>Before running our command (one that jumps around the buffer, a lot), we save
40our view, and restore it once its done, with <code>winrestview</code>.</p>
41
42<pre><code>let view = winsaveview()
43s/\s\+$//gc &quot; find and (confirm) replace trailing blanks
44winrestview(view) &quot; restore our original view!
45</code></pre>
46
47<p>It might seem a little overkill in the above example, just use &#8220; (double
48backticks) instead, but it comes in handy when you run your file through
49heavier filtering.</p>
50
51 </div>
52 <a href="/" class="post-end-link">⟵ Back</a>
53 <div class="separator"></div>
54 </div>
55 </div>
56 </body>
57</html>