From 5924e263893ac8c47a22a78c88b46c585fc9e82b Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 25 Jan 2020 23:14:36 +0530 Subject: update styles, minify links --- docs/posts/hold_position!/index.html | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 docs/posts/hold_position!/index.html (limited to 'docs/posts/hold_position!') 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 @@ + + + + + + + + + + + + + +
+
+
+ 30/07 2019 + + + 487b33f + + +
+ + Hold Position! + +
+

Often times, when I run a vim command that makes “big” changes to a file (a +macro or a :vimgrep command) I lose my original position and feel disoriented.

+ +

Save position with winsaveview()!

+ +

The winsaveview() command returns a Dictionary 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.

+ +

Before running our command (one that jumps around the buffer, a lot), we save +our view, and restore it once its done, with winrestview.

+ +
let view = winsaveview()
+s/\s\+$//gc              " find and (confirm) replace trailing blanks
+winrestview(view)        " restore our original view!
+
+ +

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.

+ +
+ ⟵ Back +
+
+
+ + -- cgit v1.2.3