Closed kleinjm closed 6 years ago
You can use <Plug><cfile>
on the command line to access the filename rails.vim hands off to :find
. Here's an example for making <Leader>f
in Rails buffers use a vertical split:
autocmd User Rails nmap <buffer> <Leader>f :vert sfind <Plug><cfile><CR>
Here's a more complicated example that works universally:
" Use Vim's built-in CTRL-R_CTRL-F when no plugin has claimed <Plug><cfile>
if empty(maparg('<Plug><cfile>', 'c'))
cnoremap <Plug><cfile> <C-R><C-F>
endif
" Helper map to pass the count (e.g., 2gf) to the underlying command
nnoremap <SID>: :<C-U><C-R>=v:count ? v:count : ''<CR>
" Map <Leader>f to vertical split
nmap <Leader>f <SID>:vert sfind <Plug><cfile><CR>
I saw this in the docs for a new window and new tab but is there a mapping or an easy way to map to opening in a new split?