Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIM编辑器安装及配置 #30

Open
abeet opened this issue Dec 5, 2017 · 0 comments
Open

VIM编辑器安装及配置 #30

abeet opened this issue Dec 5, 2017 · 0 comments

Comments

@abeet
Copy link
Owner

abeet commented Dec 5, 2017

VIM下载地址为
http://www.vim.org/download.php
网上有一个neovim,说是vim的分支上作了很多改进,但也有人说不成熟就不用了。

下载window下的安装包,安装完后打开界面空空的,当然要去找插件了,
在github上搜索 vim distribution 会发现有一个标星非常多的项目
https://github.com/spf13/spf13-vim
安装起来要费点工夫,
http://msysgit.github.io/
先安装git的命令行工具msysgit,
下载msysgit2.x老不成功,在另外一个网站上找到
Git-1.9.2-preview20140411.exe
的下载地址,也许是因为镜像多,用迅雷下载成功。
安装过程中记得勾选安装命令行工具集。

还要装curl.exe,但我发现命令行里已经有curl.exe了,不知道是msysgit带的还是windows自带的。

https://github.com/spf13/spf13-vim
里的说明在 git\cmd目录下新建了 curl.cmd。

执行curl https://j.mp/spf13-vim3 -L -o - | sh
没有成功,说 HOME 找不到,只能参考curl.cmd手动设置一下HOME。

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

执行curl https://j.mp/spf13-vim3 -L -o - | sh
安装 spf13-vim3 但安装到哪了我也不记得了。。
进入vim的输入 :echo $HOME 得到 home文件所在的路径 C:\Users\abeet
找到 C:\Users\abeet\.spf13-vim-3 目录下的
spf13-vim-windows-install.cmd 以管理员身份运行之,
会有十几分钟的插件安装过程。
全部插件安装完成后,再找到gvim.exe,就发现界面已经变了,查看已安装的插件的命令是在vim里输入
:BundleList
可以看到有插件 neocomplete,没有youcompleteme
试写js,发现没有自动完成功能,注意到状态栏里有提示,大意是因为没有lua 导致 neocomplete 插件不能用。

又到网上搜索 neocomplete 插件的安装。
neocomplete 依赖 lua,首先 vim得用支持lua的版本。
vim里输入
:version 发现 -lua,表示不支持lua。
但我又不想自己编译,就去找已经编译好的。

http://wyw.dcweb.cn/index.htm#download
http://wyw.dcweb.cn/vim/gvim80.zip

从这儿下载了新的,覆盖原来的gvim.exe vim.exe。
还有其他几个下载地址记下备用
https://github.com/vim/vim-win32-installer/releases
https://tuxproject.de/projects/vim/

新的gvim输入
:version 发现 +lua/dyn,表示支持lua。
那么是否支持lua?在vim里执行lua语句测试
:lua print('asdf') 会有出错提示 因为 lua51.dll没有找到执行lua失败。
又去网上找lua51.dll。百度信不过,在bing里搜索lua51.dll然后在
http://originaldll.com/file/lua5.1.dll/22745.html
找到下载地址,下载得到 lua5.1.dll 重命名为 lua51.dll放入到 gvim.exe同一目录下,
再执行
:lua print('asdf')
成功,这时 neocomplete 插件可以用了。

参考文章:
http://www.bubuko.com/infodetail-1876966.html

设置使用相对行号

    set number            " Line numbers on
    set relativenumber    " 使用相对行号
    set nospell           " 不要拼写检查

设置字号,搜索guifont

                set guifont=Andale_Mono:h11,Menlo:h11,Consolas:h11,Courier_New:h11

设置退出时保存Session(注意经测试expand方法转换路径是必须的)
中间遇到两个问题,查了半天资料才改成下面这样,

" Auto Session Save/Restore
function! SaveSession()
    if (!isdirectory('~/.vim'))
		call mkdir('~/.vim')
	endif
	execute 'mksession! ~/.vim/session.vim'
endfunction

function! RestoreSession()
    if argc() == 0
		if filereadable(expand('~/.vim/session.vim'))
			execute 'source ~/.vim/session.vim'
			if bufexists(1)
				for l in range(1, bufnr('$'))
					if bufwinnr(l) == -1
						exec 'sbuffer ' . l
					endif
				endfor
			endif
		else
			echo 'No session loaded.'
		endif
	endif
endfunction

"NERDTree doesn't support session, so close before saving
autocmd VimLeave * :NERDTreeClose
autocmd VimLeave * call SaveSession()
autocmd VimEnter * nested call RestoreSession()

set sessionoptions-=options

对调键盘上 CapsLock键 与 Ctrl键位置

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00
  • 代码格式化
    默认的js风格检查插件用的是standard
    见文件

C:\Users\abeet.vim\bundle\syntastic\doc\syntastic-checkers.txt
let g:syntastic_javascript_checkers = ["standard"]

但standard对jsx的格式化可能并不好,这时我们可以使用格式化更完美的prettier
有一个配合standard的prettier格式化工具,见prettier-standard
先安装命令行工具npm install -g prettier-standard
再在vim的配置文件.vimrc里添加autocmd FileType javascript set formatprg=prettier-standard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant