简体   繁体   中英

VIM get E488: Trailing characters error

I'd like to implement a function that can get VirtualEnv name from a file named .env and then execute CondaChangeEnv VirtualEnvName.

function! SetVirtualEnv()
    let cmd = "sed -n '1,1p' ". $PWD . "/.env"
    let result = 'CondaChangeEnv ' . system(cmd)
    if !v:shell_error
        exe result
    endif
endfunction
autocmd FileType python call SetVirtualEnv()

But, it seems like something is wrong

E488: Trailing characters: CondaChangeEnv G

G is the content of .env and generated by echo -n 'G' >> .env

So, anybody can help me? Thanks in advance :)

If you check the source codes of your plugin:

command! CondaChangeEnv call s:CondaChangeEnv()

The CondaChangeEnv command expects no parameter, but you passed a G to it. That's the cause of your problem.

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