How to run a vim script interactively from vim command line?

后端 未结 4 760
伪装坚强ぢ
伪装坚强ぢ 2021-02-14 05:32

Is there a way to run these scripts from the : commandline with a few keystrokes?

Over the last couple of months, I\'ve built a series of fi

相关标签:
4条回答
  • 2021-02-14 05:47

    Script or function? If it is a function, try

    :call FunctionName() 
    
    0 讨论(0)
  • 2021-02-14 05:49

    Open Vim and enter the following:

    :source /path/to/vim/file/name.vim
    

    If you are currently editing that file, you can also type:

    :w <ENTER>
    :source % <ENTER>
    

    The percent sign (%) means the path to the currently opened file.

    0 讨论(0)
  • 2021-02-14 05:59
    :run file.vim
    

    :run is like :source, but :run doesn't need the path. It searches the runtimepath.

    A Linux runtimepath:

    $HOME/.vim,
    $VIM/vimfiles,
    $VIMRUNTIME,
    $VIM/vimfiles/after,
    $HOME/.vim/after
    
    0 讨论(0)
  • 2021-02-14 06:01

    You could use the command feature of vim. In your unit_test_cpp.vim file you would add something like this:

    command Utc call CreateUnitTests()
    

    Now when you type :Utc it will call your function. The only limitation is that your command must start with an uppercase letter.

    0 讨论(0)
提交回复
热议问题