在PowerShell中使用Vim

来源:互联网 发布:淘宝我订购的应用 编辑:程序博客网 时间:2024/05/09 09:47

原文出处。蜗窝科技,http://www.wowotech.net/soft/vim_in_powershell.html

蜗蜗想要的无非就是一个命令行的环境,加上Vim工具。而微软在WIN7、WIN8时,就在系统中集成了一个Shell工具----PowerShell,这个工具虽然没有Linux系统的Shell强大,但相比Windows的Command Line,还是强大不少。那是否可以利用它呢?答案是肯定的。

首先,需要去Vim官网下载并安装一个可运行于Win8系统的执行文件。

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

  • 以管理员的身份运行PowerShell
  • 执行Set-ExecutionPolicy RemoteSigned命令,在对话框中选择Y,如下
    1. PS C:\Windows\system32> 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:\Windows\system32>

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

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

最后,编辑配置文件(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后,就可以正常使用了,如下(后续可以按照正常的方式,配置VIM,这里就不多说了)。vim_in_powershell.gif

 


1 1
原创粉丝点击