Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

save and restore last cursor position in vim

  • Loading branch information...
commit fd583da91a752d3f7a7af493c91c12069706c9f9 1 parent 95ed1a1
@knutwalker authored
Showing with 14 additions and 1 deletion.
  1. +14 −1 .vimrc
View
15 .vimrc
@@ -19,6 +19,11 @@ let mapleader=","
" Don’t add empty newlines at the end of files
set binary
set noeol
+" read/write a ~/.viminfo file, don't store more
+" than 20 files and 50 lines/commands per file
+set viminfo='20,\"50,:50,%,n~/.viminfo
+" keep 50 lines of command line history
+set history=50
" Centralize backups, swapfiles and undo history
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
@@ -93,4 +98,12 @@ if has("autocmd")
filetype on
" Treat .json files as .js
autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
-endif
+ augroup cursor
+ autocmd!
+ " When editing a file, always jump to the last cursor position
+ autocmd BufReadPost *
+ \ if line("'\"") > 0 && line ("'\"") <= line("$") |
+ \ exe "normal! g'\"" |
+ \ endif
+ augroup END
+endif
Please sign in to comment.
Something went wrong with that request. Please try again.