Sunday, April 29, 2012

Cursor anomoly: apparent and actual positions differ

All,

I've noticed some strange cursor behavior when following one of
the Wiki tips. Below is a 26-line-long file to describe and
demonstrate the problem.

" ----------- start of "cursor-pos-anomoly.txt" ------------------
" To show anomoly, launch Vim as:
" vim -u NONE cursor-pos-anomoly.txt "+source %"
"
" This demonstrates a cursor anomoly (apparent vs. actual position).
"
set nocp | set hls | /^" \(Start\|End\)
"
" From http://vim.wikia.com/wiki/Avoid_scrolling_when_switch_buffers:
" When switching buffers, preserve window view.
if v:version >= 700
au BufLeave * let b:winview = winsaveview()
au BufEnter * if exists('b:winview') | call winrestview(b:winview) | endif
endif
"
" You should initially find the cursor on the following line:
" Start on this line
"
" End seemingly on this line after running the two commands below:
"
" :copen
" CTRL-W CTRL-W
"
" But you're actually still on the "Start" line, which you can see by
" pressing one of these three keys, for example: C D j
" ------------- end of "cursor-pos-anomoly.txt" ------------------

The fact that the cursor appears to be on one line but is
functionally on another seems like a bug to me.

As a separate issue, I don't see anything wrong with the logic
in the wiki tip, but perhaps someone has a better suggestion to
achieve the tip's goal.

Thanks,
Michael Henry

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment