vim + spf13

 

参考:html

pc
-----
https://ftp.nluug.nl/pub/vim/pc/gvim81.exe

mac
-----
https://github.com/macvim-dev/macvim/releases
$ brew install vim --with-cscope --with-lua --override-system-vim
安装spf13-vim见下面linux部分。
若是安装macvim,将上面的vim替换为macvim,而后执行 brew linkapps macvim
 
linux
-----
https://github.com/vim/vim
$ sudo apt-get remove --purge vim
$ sudo apt-get autoclean
$ sudo apt-get install python-dev python3-dev ruby-dev luajit liblua5.1-dev libluajit-5.1 libperl-dev libncurses5-dev
$ sudo rm -rf /usr/local/share/vim
$ sudo rm /usr/bin/vim
$ sudo mkdir -p /usr/include/lua5.1/include
$ sudo cp /usr/include/lua5.1/*.h /usr/include/lua5.1/include/
$ cd ~
$ git clone --depth 1 https://github.com/vim/vim.git
$ cd ~/vim/src
$ make distclean
$ ./configure --with-features=huge \
--enable-largefile \
--enable-multibyte \
--enable-perlinterp \
--enable-rubyinterp \
--enable-luainterp \
--enable-python3interp \
--with-python3-config-dir=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu \
--with-luajit \
--enable-fail-if-missing \
--with-lua-prefix=/usr/include/lua5.1 \
--enable-cscope \
--enable-gui=auto

注意:python3 和 python 同时给定,优先会使用python
--enable-pythoninterp \
--with-python-config-dir=/usr/lib/python2.7/config \

$ make -j8
$ sudo make install

$ whereis vim
vim: /usr/local/bin/vim /usr/share/man/man1/vim.1
$ vim --version



安装spf13-vim
----vim-plugs版本----
https://github.com/junegunn/vim-plug/wiki
cd ~
pip3 install neovim
curl https://raw.githubusercontent.com/StarryLeo/starry-vim/master/bootstrap.sh -L > starry-vim.sh && sh starry-vim.sh
或者
sh <(curl https://raw.githubusercontent.com/StarryLeo/starry-vim/master/bootstrap.sh -L)
添加go-vim插件
echo "Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }" >> ~/.vimrc.plugs.local
vim +PlugClean! +PlugInstall +q
查看状态,清理错误的插件后再从新安装
:PlugStatus
:PlugClean
:PlugInstall

删除一个插件
echo UnPlug 'scrooloose/syntastic' >> ~/.vimrc.plugs.local
更新:
cd ~/.starry-vim/
git pull
vim +PluginClean! +PlugInstall +q

----原始Vundle版本----
$ sudo apt-get install exuberant-ctags
$ curl http://j.mp/spf13-vim3 -L -o - | sh
或者
$ curl https://raw.githubusercontent.com/spf13/spf13-vim/3.0/bootstrap.sh -L -o - | sh
会出现amirh/HTML-AutoCloseTag错误(提示是登录github),按Ctrl+w,jj跳过这个错误
所有安装后
$ vim ~/.vimrc.bundles
找到amirh,替换为okayliao,保存退出后用下面命令从新安装一遍插件。
$ vim +BundleInstall! +BundleClean +q


快捷键:
开启行号(简写nu)
:set number
开启相对行号(简写rnu)
:set relativenumber
向上移动相对8行:g.8k
向下移动相对8行:g.8j
向下删除到相对4行:d4j
重复上个命令:.
浏览旧文件(简写bro old)
:browse oldfile
最近编辑过的文件('0~'9)
'0
切换TAB
[num]gt
切换缓冲(简写b<num>)
:buffer <num>

打开NERD_Tree目录树:C-e或者,e
查找文件打开:C-p
注释:,cc
跳转:,,fa  ,,b

Surround
https://github.com/tpope/vim-surround/blob/master/doc/surround.txt
Old text                  Command     New text                        Comment
"Hello *world!"           ds"         Hello world!                    删除双引号
[123+4*56]/2              cs])        (123+456)/2                     改变[]为(),若是用左括号将使括号内插入空白间隙
"Look ma, I'm *HTML!"     cs"<q>      <q>Look ma, I'm HTML!</q>       改变双引号为html标记,改变回来可用cst"
if *x>3 {                 ysW(        if ( x>3 ) {                    iw是一个文本对象,t是tag,W是空白
my $str = *whee!;         vllllS'     my $str = 'whee!';              S是选中范围
支持repeat.vim的命令(.重复命令):ds(删除)、cs(改变)和yss(整行)

开启行号、关闭拼写检查、自动折叠、行号显示、调整字体大小
vim ~/.vimrc.local
内容开始
set number relativenumber
set nospell
set nofoldenable
let g:DisableAutoPHPFolding = 1

if has('gui_running')
    set guioptions-=T           " Remove the toolbar
        set lines=40                " 40 lines of text instead of 24
        if !exists("g:starry_no_big_font")
            if LINUX() && has("gui_running")
                set guifont=Consolas-with-Yahei:h12
        elseif OSX() && has("gui_running")
            set guifont=Andale\ Mono\ Regular:h14,Menlo\ Regular:h13,Consolas\ Regular:h14,Courier\ New\ Regular:h16
        elseif WINDOWS() && has("gui_running")
            set guifont=Consolas-with-Yahei:h10.5
        endif
    endif
else
    if &term == 'xterm' || &term == 'screen'
        set t_Co=256            " Enable 256 colors to stop the CSApprox warning and make xterm vim shine
    endif
    "set term=builtin_ansi       " Make arrow and other keys work
endif
内容结束


备份:
TARGET=$HOME/Desktop/vimrc.tar.xz
cd ~ && rm -rf $TARGET && tar cvJfp ~/Desktop/vimrc.tar.xz .starry-vim/ .vim/ .vimrc.local .vimrc.plugs.local starry-vim.sh
unset TARGET
在桌面生成vimrc.tar.xz文件

恢复:
TARGET=$HOME
mkdir -p $TARGET
tar xvJf ~/Desktop/vimrc.tar.xz -C $TARGET
ln -s $TARGET/.starry-vim/.vimrc $TARGET/.vimrc
ln -s $TARGET/.starry-vim/.vimrc.before $TARGET/.vimrc.before
ln -s $TARGET/.starry-vim/.vimrc.plugs $TARGET/.vimrc.plugs
sudo chmod 755 $TARGET/.vimrc{,.before,.plugs}
unset TARGET

 

图片:python

VIM KEYBOARD

 

打印和高清版本,请访问:http://michael.peopleofhonoronly.com/vim/linux

相关文章
相关标签/搜索