Save exact cursor position in the line

I am looking way to make Vim save my exact cursor position when I exit it or switch between buffers.

I have the following configuration in my config:

autocmd BufReadPost *
  \ if line("'\"") > 0 && line ("'\"") <= line("$") |
  \ exe "normal g'\"" |
  \ endif

it only returns the cursor to the beginning of the line where my cursor was, but not the position of the cursor in it; i.e. my cursor returns to the beginning of the line, not where it was in it.

Is there any way to bring back the exact position of the cursor?


P.S. I am new in Vim

Read more here:

Content Attribution

This content was originally published by KarlsD at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: