8

A plugin defines a function named HLMarks():

hi Marks term=reverse ctermfg=0 ctermbg=40 guibg=Grey40

function! HLMarks(group)
    call clearmatches()
    let index = char2nr('a')
    while index < char2nr('z')
        call matchadd( a:group, '\%'.line( "'".nr2char(index)).'l')
        let index = index + 1
    endwhile
endfunction

I want the HLMarks() function to run automatically every time vim opens a file. It works when I call the function manually:

:call HLMarks("Marks")

Adding this line to the end of the plugin didn't do anything:

call HLMarks("Marks")

Calling the function from vimrc got this error:

E117: Unknown function: HLMarks

How to automatically call the HLMarks("Marks") function when a file is opened?

The plugin is described on http://www.vim.org/scripts/script.php?script_id=3394 and down loaded from http://www.vim.org/scripts/download_script.php?src_id=21611

The plugin's markHL.vim file is in my ~/.vim/plugin/ directory.

The ":function" command lists:

function HLMarks(group)

2 Answers 2

4

The solution is to add this line to vimrc:

autocmd BufReadPost * call HLMarks("Marks")

Details are at https://groups.google.com/forum/#!topic/vim_use/i2HWD_9V-28

Sign up to request clarification or add additional context in comments.

Comments

2

If you define the function in .vimrc then:

function! yourFunc()
    " ...
endfunction

call yourFunc()

simply adding the call yourFunc() after the definition will work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.