Error when trying to add visible marks in vim

0

I am trying to use visible markers in vim.
I have the following in my .vimrc file:

sign define information text=!> linehl=Warning texthl=Error  
exe ":sign place 123 line=" . line(.) ."name=information file=" . expand("%:p")  
map <F7> :exe ":sign place 123 line=" . line(".") ."name=information file=".expand("%:p")<CR>  

But when I open vim I get an error in line exe ":sign etc

line   30:  
E15: Invalid expression: .) ."name=information file=" . expand("%:p")  
E116: Invalid arguments for function line(.) ."name=information file=" . expand("%:p")  
E15: Invalid expression: ":sign place 123 line=" . line(.) ."name=information file=" .   expand("%:p")

What is the problem with my syntax?

user65971

Posted 2013-06-23T09:02:02.723

Reputation: 317

:s/visible marks/signs – romainl – 2013-06-23T10:18:03.287

@romainl:What is this command? – user65971 – 2013-06-23T10:32:19.757

An inside joke and a comment: you should call them "signs" instead of "visible marks". – romainl – 2013-06-23T11:30:48.803

Answers

2

The error is fairly easy to spot.

You wrote

line(.)

instead of

line('.') or line(".")

edit

The error message in your question was related to the error above but there's a second error, a missing space.

  1. Your line:

    exe ":sign place 123 line=" . line(.) ."name=information file=" . expand("%:p")
    
  2. First error corrected by putting the argument to line() in quotes (fixed expand() as well):

    exe ":sign place 123 line=" . line('.') ."name=information file=" . expand('%:p')
    
  3. Second error corrected by adding a missing space after the third double quote:

    exe ":sign place 123 line=" . line('.') ." name=information file=" . expand('%:p')
                                              ^
                                              +-- added missing space
    

Because of the missing space, the value of the line argument was something like 26name=information and the name argument was missing.

romainl

Posted 2013-06-23T09:02:02.723

Reputation: 19 227

If I write:exe ":sign place 123 line=" . line('.') ."name=information file=" . expand("%:p") I still get an error on this line about E474 Invalid argument – user65971 – 2013-06-23T15:04:42.587

Same problem with exe ":sign place 123 line=" . line(".") ."name=information file=" . expand("%:p") – user65971 – 2013-06-23T15:06:14.867

You need to use single quotes inside the surrounding double quotes: :exe "echo 'This is line number " . line('.') . ". You bet it is.'". If you don't do that Vim will get lost trying to figure where the expression to execute ends. – romainl – 2013-06-23T15:25:04.793

This exe ":sign place 123 line=' . line('.') .'name=information file=" . expand("%:p") does not work either. I am not sure I understand which part you mean that should be corrected – user65971 – 2013-06-23T15:54:25.597

Your command echo is straitforward.But in my case I am not sure which part should be in single quotes – user65971 – 2013-06-23T16:11:44.153

@user65971, see my edit. – romainl – 2013-06-23T16:31:12.687

The . are appending like in perl? Also why did the expand needed single quotes? It was outside of double quotes – user65971 – 2013-06-23T16:44:26.613

Actually, the quotes don't matter in this case, it's a legibility/convention issue. You may not care about that but I do. I'm not familiar with Perl but concatenation works pretty much like in PHP: "abc" . "def" produces "abcdef" while "abc" . " def" produces "abc def". – romainl – 2013-06-23T16:52:07.183