2016年3月

未命名文档

安装Vundle

  • git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
  • 配置 ~/.vimrc 参考 readme.md
  • 打开vim
  • :BundleInstall

安装vim-emmet

配置 ~/.vimrc 添加 Plugin 'mattn/emmet-vim'

格式化html/css/js代码

:%! html-beautify -f - 或者 :! js-beautify --type html -f -
:%! css-beautify -f - 或者 :! js-beautify --type css -f -
:%! js-beautify -f -

改变窗口的大小(分割)

  • :res +n 竖直增加n个字符
  • :res -n 竖直减少n个字符
  • :vertical res +n 水平增加n个字符
  • :vertical res -n 水平减少n个字符

配置netrw

 " Toggle Vexplore with Ctrl-E
 function! ToggleVExplorer()
   if exists("t:expl_buf_num")
     let expl_win_num = bufwinnr(t:expl_buf_num)
     if expl_win_num != -1
       let cur_win_nr = winnr()
       exec expl_win_num . 'wincmd w'
       close
       exec cur_win_nr . 'wincmd w'
       unlet t:expl_buf_num
     else
       unlet t:expl_buf_num
     endif
   else
     exec '1wincmd w'
     Vexplore
     let t:expl_buf_num = bufnr("%")
   endif
 endfunction
 map <silent> <C-E> :call ToggleVExplorer()<CR>

 " Hit enter in the file browser to open the selected
 " file with :vsplit to the right of the browser.
 let g:netrw_browse_split = 4
 let g:netrw_altv = 1

 " Change directory to the current buffer when opening files.
 set autochdir

向前跳转或向后跳转

ctrl+o ctrl+i

格式化CSS

:%!js-beautify --type css -f %

复制粘贴系统剪切板

select any range
"+y
"+p

统计查找内容次数

:%s/CONTENT//gn

用某种指定编码重新打开文件

:e ++enc=gbk

用VIM打开命令行结果

javap -verbose net.rancy.OdoraClass | vim -

让VIM支持vue后缀文件

au BufNewFile,BufRead *.vue set filetype=html

VIM look ahead

/keyword\(ahead\)\@=

cursor

set colorline
set colorcolumn

indent

" 显示tab和空格
set list
" 设置tab和空格样式
set lcs=tab:\|\ ,nbsp:%,trail:-
" 设定行首tab为灰色
highlight LeaderTab guifg=#666666
" 匹配行首tab
match LeaderTab /^\t/

filetype

set encoding=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,big5,sjis,latin1
set nowrap
set ignorecase
set nobackup
set nowritebackup
set noincsearch
set hlsearch
set cursorline
set cursorcolumn
set list
set lcs=tab:\|\ ,nbsp:%,trail:-
highlight LeaderTab guifg=#666666
match LeaderTab /^\t/

syntax on
syntax enable
filetype plugin indent on
au BufNewFile,BufRead *.ftl set filetype=html

set si
set noet
set ts=4
set sw=4
autocmd filetype javascript  setlocal et sta sw=2 sts=2 ts=2
autocmd filetype html,css    setlocal noet sta sts=4
autocmd filetype java,python setlocal noet sta sts=4

html format

:let g:html_indent_inctags = "html,body,head,tbody"

set bomb

:set bomb
:set nobomb
:set bomb?

lftp的问题

用lftp连接remote服务器后产生如下错误

 Fatal error: Certificate verification: Not trusted

则需要设置

 set ssl:verify-certificate no

上传整个目录

mirror -R localdir

下载整个目录

mirror remotedir localdir

查看所有设置值

set -a

设置字符集

set file:charset utf-8
set ftp:charset utf-8

设置模式

set ftp:passive-mode off