PowerShell使用Vim的方法
shell
最近一直在Windows平台下测试Git代码管理的功能,由于本身代码写的十分乱,想要快速掌握Git的用法来对代码进行管理。我发如今Powershell下却不能使用Vim进行编辑,这让我十分难受,毕竟习惯了在Linux下操做。下面来看看怎么可以在Powershell下使用Vim。vim
一、去Vim官网下载适合操做系统的可执行文件测试
由于我下的GitHub安装包里自带了vim,因此我就直接进行的配置。this
二、找到Vim文件夹中的vimrc文件进行修改,增长下面这4行。spa
set encoding=utf-8 set termencoding=utf-8 set fileencoding=utf-8 set fileencodings=ucs-bom,utf-8,chinese,cp936三、在C:\Windows\System32\WindowsPowerShell\v1.0目录下新建profile.ps1文件,复制下面的代码到profile.ps1文件中。
# There's usually much more than this in my profile! $SCRIPTPATH = "C:\Program Files (x86)\Vim" $VIMPATH = $SCRIPTPATH + "\vim80\vim.exe" Set-Alias vi $VIMPATH Set-Alias vim $VIMPATH # for editing your PowerShell profile Function Edit-Profile { vim $profile } # for editing your Vim settings Function Edit-Vimrc { vim $home\_vimrc }四、重启Shell,执行Set-ExecutionPolicy RemoteSigned命令修改模式就能够了。
Set-ExecutionPolicy RemoteSigned
Powershell已经能够正常使用vim了!操作系统