Ilia N Ternovich wrote:
Hi all!
I'm trying to make recent.vim plguin working with vim-7.0
There is some kind of problem with mapping keys inside plugin:
function! OptionFiles()
"let file = bufname("%")
if bufname("")=="recent_files"
map <Enter> gf
set number
set noswapfile
else
set nonumber
set swapfile
if hasmapto('gf')
unmap gf
endif
endif
endfunction
command Recent edit ~/.vim/recent_files
autocmd BufEnter * :call OptionFiles()
I wonder why this function doesn't map Enter key to "gf" combination, when
I start vim... There is succesfully created "recent_files" buffer... But
keybinding doesn't work :(
Can anybody help me with this question
This is a bit off topic, but you probably want your function to look
like this:
function! OptionFiles()
"let file = bufname("%")
if bufname("")=="recent_files"
map <buffer> <Enter> gf
setlocal number
setlocal noswapfile
endif
endfunction
Not sure it will help with your problem, but this way all the changes are
buffer local.