Posted by: songbard | December 12, 2008

Linux trivia : vi settings

Ever faced the problem of cursor getting reset to beginning of file each time you open it in vi! Well, adding the following to .vimrc in your home directory or /etc/vimrc (whichever is appropriate) will get the cursor back to where you left it in last session.

if has(“autocmd”)
” In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
” When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line(“‘\””) > 0 && line (“‘\””) <= line(“$”) |
\   exe “normal g’\”” |
\ endif
endif

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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 )

Google+ photo

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

Connecting to %s

Categories

%d bloggers like this: