From 366df8852f503523cc4f9046d82ba9a99dd51d7f Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 12 Feb 2023 12:13:49 +0530 Subject: new art: lapse --- docs/posts/hold_position!/index.html | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'docs/posts/hold_position!') 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 @@ 30/07 — 2019
- 9.18 + 9.19 cm   @@ -42,14 +42,24 @@ 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.

+

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.

+

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.

+

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.

-- cgit v1.2.3