PowerShell使用Vim的方法

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了!操作系統