1

I am searching for a way to execute a line under the cursor as a command. I assign it to a combination of <Leader>el and basically I found a way to do it with :exe !@u but the issue I have here is that special chars like # and % get expanded by vi as well. And I want the entire string in the named register to be executed literally as is. I tried with :call system(@u) but to no avail. Can you please help?

  • 2
    Vi or Vim? I think you mean :exe '!'.@u . What if you change :call system(@u) to echo system(@u). Might be related: vi.stackexchange.com/questions/14300/… . – dedowsdi May 8 at 1:50
  • Seconded: vi or vim? I have a mapping for this in my vim filetype settings: nnoremap ... :execute getline('.')<CR> to execute vimscript. system does something different. – D. Ben Knoble May 8 at 2:18
  • Depends on what you want to run. – D. Ben Knoble May 8 at 4:55
  • @D.BenKnoble it’s vim. Either way, I already tried with :exe. It didn’t work for me. Perhaps your vim is compiled or configured differently than mine.. – George Mogilevsky May 9 at 10:53
0

As per the comment of @dedowsdi, echo system(@u) worked. This is the answer. Unfortunately I cannot even upvote your comment. But you get the credit! Thank you so much!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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