How to make the vim call function in .bashrc?

后端 未结 5 2179
春和景丽
春和景丽 2021-01-04 05:57

Environment: debian9+vim7.4.

   cat .bashrc
   add(){
        echo $(expr $1 + $2)
    }

Now edit a file in vim

add 1 5         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 06:06

    I suppose this should solve it for you. It's more of a workaround than an explanation of you problem but it gets the job done

    :execute '! source ~/.bashrc; source '.expand('%:p')
    

    I'm just manually sourcing bashrc before calling the command. One possible explanation to your problem is if you are on a mac. As far as I know OSX don't source bashrc, they do source bash_profile though.

提交回复
热议问题