Match leader including file name

I am currently using this:

nnoremap <leader>c :ConqueTermSplit ruby 

that leads to:

:ConqueTermSplit ruby 

What I'm trying to do is create a leader key that will lead to

:ConqueTermSplit ruby ex1.rb<cr>

Given that the file I'm working with is called ex1.rb

I am a little confused about how I will do this.

+3
source share
1 answer

if

"file I'm working with"

you meant the file in your current buffer, you could just create a mapping with <expr>:

nnoremap <expr> <leader>c ':ConqueTermSplit ruby ' . expand("%p:%h"). "\<cr>"

related reference document:

:h <expr>
:h expand(

a safer solution will be wrapped expand(..)using the method shellescap()if the path to this file has special characters.

or save expand(...)using case %and shellescape():

 nnoremap <expr> <leader>c ':ConqueTermSplit ruby ' . shellescape(@%,1). "\<cr>"
+6
source

All Articles