aboutsummaryrefslogtreecommitdiff
path: root/docs/posts/hold_position!.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/posts/hold_position!.html')
-rw-r--r--docs/posts/hold_position!.html47
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/posts/hold_position!.html b/docs/posts/hold_position!.html
new file mode 100644
index 0000000..a0f3fdf
--- /dev/null
+++ b/docs/posts/hold_position!.html
@@ -0,0 +1,47 @@
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="post posts">
15 <div class="date">30/07 2019</div>
16 <span style="font-size: 2rem; font-weight: 600">
17 Hold Position!
18 </span>
19 <div class="post-text">
20 <p>Often times, when I run a vim command that makes &#8220;big&#8221; changes to a file (a
21macro or a <code>:vimgrep</code> command) I lose my original position and feel disoriented.</p>
22
23<p><em>Save position with <code>winsaveview()</code>!</em></p>
24
25<p>The <code>winsaveview()</code> command returns a <code>Dictionary</code> that contains information
26about the view of the current window. This includes the cursor line number,
27cursor coloumn, the top most line in the window and a couple of other values,
28none of which concern us.</p>
29
30<p>Before running our command (one that jumps around the buffer, a lot), we save
31our view, and restore it once its done, with <code>winrestview</code>.</p>
32
33<pre><code>let view = winsaveview()
34s/\s\+$//gc &quot; find and (confirm) replace trailing blanks
35winrestview(view) &quot; restore our original view!
36</code></pre>
37
38<p>It might seem a little overkill in the above example, just use &#8220; (double
39backticks) instead, but it comes in handy when you run your file through
40heavier filtering.</p>
41
42 </div>
43 <a href="/index.html" class="post-end-link">‹ Back</a>
44 <div class="separator"></div>
45 </div>
46 </body>
47</html>