Displaying unwanted control characters in vimscript function output
[using MacVim 7.3 on OS X Lion]
I have a vimscript function that runs an external command. He performed well, but the output is displayed (unwanted) control characters, such as [0m
, [33m
, [36m
and -1H
. Relevant line in vimscript function:
exec ":!bundle exec rspec --color " . a:filename
What produces:
:!bundle exec rspec --color spec/acceptance/user_logs_in.feature
[33m*[0m
Pending:
[33m User logs in [0m
[36m # the step 'the user "foo@test.host" exists' is not implemented[0m
[36m # [0m
Finished in 0.07121 seconds
[33m1 example, 0 failures, 1 pending[0m
Here's what the same command and output looks like from the terminal, what I want it to display in vim:
$ bundle exec rspec --color spec/acceptance/user_logs_in.feature
*
Pending:
User logs in
# the step 'the user "foo@test.host" exists' is not implemented
#
Finished in 0.1161 seconds
1 example, 0 failures, 1 pending
Also, anytime I execute a command and an external command, vim displays -1H
right after it. For example, if I type:
:ls<return>
I see:
:ls-1H
<rest of the output is as expected>
Any ideas on hiding these control characters and -1H
.
(disclaimer: I'm very new to vim, so please don't take too much background knowledge on my part.)
Thank.
Update 3/31/2012 @ 17:32
Sam Goldman is correct: MacVim doesn't know how to display colors, so it outputs color codes.
I switched to a vim terminal (which supports colors, at least with iTerm ), but using the version of vim that comes with MacVim, which is more modern and compiled with Ruby support (among other things). The easiest way to do it:
brew install macvim --override-system-vim
source to share