The |
separates Vim commands; for Vim, the mapping ends at the first |
, and Vim tries to interpret the remainder as a command (which obviously fails). You need to either escape via \
or (better) use the special <Bar>
notation in mappings:
:nnoremap ,t :!ruby -e "Dir.glob('./spec/*_spec.rb').each {<Bar>f<Bar> require f}"<cr>
Tips
You should use :noremap
; it makes the mapping immune to remapping and recursion.
Bonus answer
You can get an upward directory search (:help file-searching
) via finddir()
, then pass the result to glob()
. See
:echo finddir('spec', '.;')
(I would then move the implementation into a :function
, and invoke that from the mapping. This would have also avoided the |
escaping problem.)