I have some commands set up that run the test under my current cursor position. using the command rails test <filename>:<linenumber>. I execute this command through exec '!rails test %:'.line('.') which works fine in most situations. However, for some reason when the line number starts with an 8 it behaves weirdly.

when testing with the command :exec '!echo "%:'.line('.').'"' i get the following outputs

line  7 -> test.txt:7
line  8 -> test.txt
line  9 -> test.txt:9
line 79 -> test.txt:79
line 80 -> test.txt0
line 89 -> test.txt9
line 90 -> test.txt:90

Even when hardcoding the number in the command it behaves similarly

!echo "%:80" results in test.txt0 Hardcoding the filename does get the correct result though !echo "test.txt:80" -> test.txt:80

This pattern repeats for the 800s as well. Am i missing something obvious?

I tried running the same test in vim --clean to make sure there weren't any plugins messing with me but it has the same behavior

  • 6
    Am I missing something obvious? :h filename-modifiers
    – Matt
    Commented Jul 28, 2022 at 20:30
  • Thanks @Matt, i was missing something obvious
    – Enermis
    Commented Jul 28, 2022 at 21:10

1 Answer 1


What I would propose is:

:exec '!echo "' . expand(%) . ':' . line('.') . '"'

What @Matt highlight is that:


Returns the 8.3 version of the current filename.

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.