简体   繁体   中英

Getting 'E488: Trailing characters' With the following function

Does anyone know why I'm getting the following error? I'm mapping the following function

function! ToggleCompileErrors()
         :if w:syntastic_is_open == 1
                 :call SyntasticReset()<CR>
                 let w:syntastic_is_open = 0
         :else
                 :call SyntasticCheck()<CR>
                 let w:syntastic_is_open = 1
         :endif
endfunction

With this command

command ToggleCompileErrors :call ToggleCompileErrors()

and it is getting called by the following keymapping

nnoremap <Leader>b :ToggleCompileErrors<CR>

And I don't know if it makes a difference but I am using neovim 0.2.2

Watch your modes. That <CR> :help key-notation is necessary for mappings , but not inside functions, which use Ex commands .

Likewise, you don't need to prefix commands inside a function with : (and this is rather odd here, especially because you're not even consistent about it). : is a normal mode command that enters command-line mode . As commands in a function already are Ex commands, the : is not needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM