在PowerShell中使用Vim

1.需要去Vim官网下载并安装一个可运行于Win8系统的执行文件(ftp://ftp.vim.org/pub/vim/pc/gvim74.exe)。

2.设置PowerShell环境,使能“allow scripts to run”选项,步骤如下:

    • 以管理员的身份运行PowerShell
    • 执行Set-ExecutionPolicy RemoteSigned命令,在对话框中选择Y,如下
  1. PS C:Windowssystem32> Set-ExecutionPolicy RemoteSigned
  2. 执行策略更改
  3. 执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 http://go.microsoft.com/fwlink/?LinkID=135170
  4. 中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
  5. [Y] 是(Y) [N] 否(N) [S] 挂起(S) [?] 帮助 (默认值为“Y”): Y
  6. PS C:Windowssystem32>

3.使用new-item命令,创建一个PowerShell的配置文件Profile。

  1. new-item -path $profile -itemtype file -force

4.编辑配置文件(notepad $profile),添加vim相关的alias。

  1. set-alias vim "C:/Program Files/Vim/Vim74/./vim.exe"
  2.  
  3. # To edit the Powershell Profile
  4. # (Not that I'll remember this)
  5. Function Edit-Profile
  6. {
  7. vim $profile
  8. }
  9.  
  10. # To edit Vim settings
  11. Function Edit-Vimrc
  12. {
  13. vim $HOME\_vimrc
  14. }

重启PowerShell后,就可以正常使用了

原文地址:https://www.cnblogs.com/phonecom/p/6358305.html