Skip to content

Instantly share code, notes, and snippets.

@ynkdir
Created September 26, 2011 10:38
Show Gist options
  • Save ynkdir/1241997 to your computer and use it in GitHub Desktop.
Save ynkdir/1241997 to your computer and use it in GitHub Desktop.
ファイルを開き直したときのカーソルのあやしい移動
ファイルを開き直したときのカーソルのあやしい移動
# make test file
$ vim -u NONE -c "call setline('.', range(1, 100))" -c "wq" foo.txt
$ vim -u NONE
:edit foo.txt " open file
:$ " move to last line
:split " split
:edit " re-open
" window 1 => cursor is on line 1
" window 2 => cursor is on last line
$ vim -u NONE
:edit foo.txt " open file
:$ " move to last line
:split " split
:edit % " re-open
" window 1 => cursor is on last line
" window 2 => cursor is on last line
$ vim -u NONE
:edit foo.txt " open file
:$ " move to last line
:new % " re-open with split
" window 1 => cursor is on last line
" window 2 => cursor is on last line
$ vim -u NONE
:autocmd BufReadPre * : " add event handler
:edit foo.txt " open file
:$ " move to last line
:split " split
:edit " re-open
" window 1 => cursor is on line 1
" window 2 => cursor is on line 1
$ vim -u NONE
:autocmd BufReadPre * : " add event handler
:edit foo.txt " open file
:$ " move to last line
:split " split
:edit % " re-open
" window 1 => cursor is on last line
" window 2 => cursor is on line 1
$ vim -u NONE
:autocmd BufReadPre * : " add event handler
:edit foo.txt " open file
:$ " move to last line
:new % " re-open with split
" window 1 => cursor is on line 1
" window 2 => cursor is on line 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment