I use https://github.com/terryma/vim-smooth-scroll and so I bind <C-d> & <C-u> to ":call smooth_scroll#down(&scroll, 5, 2)<CR>" & ":call smooth_scroll#up(&scroll, 5, 2)<CR>" respectively. However I would like <C-d> & <C-u> to default to their original behaviour if the smooth scroll plugin isn't loaded.
I've tried this:
if exists('g:loaded_smoothscroll')
noremap <silent> <C-u> :call smooth_scroll#up(&scroll, 5, 2)<CR>
noremap <silent> <C-d> :call smooth_scroll#down(&scroll, 5, 2)<CR>
endif
but strangely it ignores the mapping if I load it like that. That means the exists('g:loaded_smoothscroll') check failed, but doing an :echo exists('g:loaded_smoothscroll') does indeed return 1. I'm guessing at the moment of sourcing the vimrc g:loaded_smoothscroll was 0, then it got set to 1 after after the mapping got read. How do I get around that?
If it helps I actually put the variable let g:loaded_smoothscroll = 1 into the plugin/smooth_scroll.vim file (which did not exist in the author's original version, I had to fork it myself). Is that the correct place to put the g:loaded_smoothscroll variable?
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment