Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim scroll setting overridden

Tags:

vim

I am trying to apply the following setting for my .tex files:

set scroll=4

I've put this both in my ~/.vimrc and in my ~/.vim/ftplugin/tex.vim file. For general files, this works fine. For .tex files, all other settings in these files are applied. But not the scroll setting.

Note: I have latex-suite installed, which is what I suspect is overriding the setting.

When I type

:verbose set scroll

I get:

  scroll=22
    Last set from ~/.vim/ftplugin/tex.vim

Note: 22 is half the height (number of lines) of the gvim window.

If I source the ~/.vim/ftplugin/tex.vim file while editing, the scroll setting is applied fine, but I want it to be applied along with the other settings at startup.

Thanks

Update:

Thanks for the good advice. It didn't work yet though. I looked at scriptnames and here's the output:

    62: /home/patrick/.vim/after/ftplugin/tex.vim
    63: /home/patrick/.vim/indent/tex.vim
    64: /usr/share/vim/vim72/syntax/bib.vim
    65: /home/patrick/.vim/ftplugin/bib_latexSuite.vim
    66: /home/patrick/.vim/after/ftplugin/bib.vim
    67: /usr/share/vim/vim72/indent/bib.vim
    68: /home/patrick/.vim/nerdtree_plugin/exec_menuitem.vim
    69: /home/patrick/.vim/nerdtree_plugin/fs_menu.vim

As you can see, I also added a bib.vim file in the after/ftplugin directory, because I'm loading 4 tabs at startup, one of which is a bib file. However, it still doesn't work.

Update 2

Well I still got the same problem, but with more information. I'm now running a Windows build of vim. Again vim claims scroll was last set in ~/.vimrc. But this gets overridden whenever

  • I open a new tab (with any old file, so the vimrc setting should still apply)
  • I resize the gvim window

Hence I no longer believe this has anything to do with latex-suite or the order in which the settings are called.

like image 725
Patrick Avatar asked Mar 28 '12 11:03

Patrick


2 Answers

I figured out a fix/hack. It probably hasn't got anything to do with latex suite or all that. It is overridden when a new tab is opened or the window is resized. A quick fix is to use

noremap <C-u> 4<C-u>

Which consequently is always used when scrolling. This also sets the scroll variable to 4, so it will apply to as well.

like image 141
Patrick Avatar answered Oct 10 '22 07:10

Patrick


Put your tex.vim in your ~/.vim/after/ftplugin directory. See :help after for the details.

Also see the output of :scriptnames to check the order in which vim loads all the script files.

like image 27
holygeek Avatar answered Oct 10 '22 09:10

holygeek