I'm using rails.vim with the command :AS which open the alternate file (like test) and split the window.

The problem is, it's always on the top and I would like to open it below the current window. I would like to know if it's possible to merge these two commands properly?

I'm able to do it with :execute 'AS' | wincmd J but is this the best way to to it?

How can I be sure it goes just below?

And how do I add it to a leader key?

  • 1
    I would suggest you create your own command that call exactly what you already have. The plugin does not seems to provide this level of customisation. As for the leader key, you can do nnoremap <leader>as :execute 'AS' | wincmd J.
    – nobe4
    Jun 10, 2016 at 13:49

1 Answer 1


You can do this in different forms.

Use the command you already created and bind this to a mapping (here with the leader key):

nnoremap <leader>as :execute 'AS' <bar> wincmd J<CR>

Or you can create a new command that acts the same way (B for below):

command! ASB :execute 'AS' | wincmd J

But using wincmd J is overwhelming, prefer the split commands :

:abo[veleft] {cmd}
:bel[owright] {cmd}

So you can have your mapping/command like so:

nnoremap <leader>as :bel AS<CR>
command! ASB :bel AS

Note that if you always want to open a split below you can set the option in your vimrc:

set splitbelow

See also:

  • :h abo
  • :h bel
  • :h command
  • :h <leader>
  • Thanks for the edit, comment and proposal. If I do nnoremap <leader>as :execute 'AS' | wincmd J when I do the leader command. I see on the command line execute 'AS' but nothing happen. nnoremap <leader>as :bel AS<cr> execute AS command but not the window mouvement.
    – Mio
    Jun 10, 2016 at 14:26
  • Updated, does it work now?
    – nobe4
    Jun 10, 2016 at 14:30
  • nnoremap <leader>as :execute 'AS' <bar> wincmd J<CR> works perfectly ! No success with nnoremap <leader>as :bel AS<CR> :) Still open on the top of the window
    – Mio
    Jun 10, 2016 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.