*NIX Tricks

[vim] Automatically jump to the last visited line when a file is reopened

Posted in vim by kousik on January 5, 2012

Put the following in your .vimrc file to automatically jump to the last visited line when a file is reopened using vim:


" This allows Vim to jump to the last position when
" reopening a file

if has("autocmd")
  au BufReadPost * if line("'\"") > 0 && line("'\"")

Alternatively, you could just reopen the file normally and then hit " '0 " (that is, single quote followed by the number zero) to get the same result.

Source: Stack Overflow

Advertisement
Tagged with: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.