[vim] how to prevent line centering upon switching between buffers

This is a discussion on [vim] how to prevent line centering upon switching between buffers within the Editors forums in Theory and Concepts category; When switching between buffers (with the bn and bp commands), vim will center the line containing the cursor - just like the z. command would do. Is there a way to convince vim to not do that? cu Philipp -- Dr. Philipp Pagel Lehrstuhl f. Genomorientierte Bioinformatik Technische Universität München http://mips.gsf.de/staff/pagel...

Go Back   Application Development Forum > Theory and Concepts > Editors

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-22-2008, 05:05 AM
Philipp Pagel
Guest
 
Default [vim] how to prevent line centering upon switching between buffers

When switching between buffers (with the bn and bp commands), vim will
center the line containing the cursor - just like the z. command would
do.

Is there a way to convince vim to not do that?

cu
Philipp

--
Dr. Philipp Pagel
Lehrstuhl f. Genomorientierte Bioinformatik
Technische Universität München
http://mips.gsf.de/staff/pagel
Reply With Quote
  #2  
Old 09-22-2008, 01:27 PM
Joachim Hofmann
Guest
 
Default Re: [vim] how to prevent line centering upon switching between buffers

Philipp Pagel wrote:
> When switching between buffers (with the bn and bp commands), vim will
> center the line containing the cursor - just like the z. command would
> do.
>
> Is there a way to convince vim to not do that?
>


Try that:

if v:version >= 700
au BufLeave * let b:winview = winsaveview()
au BufEnter * if (exists('b:winview')) | call winrestview(b:winview) | endif
endif " 700


Joachim
Reply With Quote
  #3  
Old 10-09-2008, 04:33 AM
Philipp Pagel
Guest
 
Default Re: [vim] how to prevent line centering upon switching between buffers

Joachim Hofmann <speicher@freenet.de> wrote:
> Philipp Pagel wrote:
> > When switching between buffers (with the bn and bp commands), vim will
> > center the line containing the cursor - just like the z. command would
> > do.


> if v:version >= 700
> au BufLeave * let b:winview = winsaveview()
> au BufEnter * if (exists('b:winview')) | call winrestview(b:winview) | endif
> endif " 700


Works exactly as I had hoped.

Thanks
Philipp

--
Dr. Philipp Pagel
Lehrstuhl f. Genomorientierte Bioinformatik
Technische Universität München
http://mips.gsf.de/staff/pagel
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:02 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.