Actually,simplicity is not simple

轻量的JS模板

这JS模板实在是太轻量了,只是个简单替换,只因为我太不喜欢不同语言的东东相互拼接。

昨天偶然看一"blog"上个有轻量的JS模板,作者的目的也是为了实现HTML代码与JS代码的分离,使得在用JS输出HTML时更方便,代码更清晰。有兴趣的可去看看 《Tempo.js : 轻量的JS模板工具类》

刚好我现做的项目有大量的HTML与JS的拼接,但作者的实现有对不适合我的代码风格,我做了些修改就运用到我的项目里,也把我修改后的代码放出来吧!写成这种形式是为了更方便的嵌入到我的项目中来,而且我也没用到更复杂的功能,最最简单的替换就够了,就像Tempo.js的作者想法:为了实现HTML代码与JS代码的分离,使得在用JS输出HTML时更方便,代码更清晰。

var Obj = {
    yyTemp: function(id, data, def){
        var dom = document.getElementById(id);
        var parseObj = dom[id] || (dom[id] = (function(html){
            html = html.replace(/([\'|\\])/gm,"\\$1")   //转义掉 \ 和 '
                        .replace(new RegExp('{([^{}]*)}','gim'), "'+(typeof data[\"$1\"] != 'undefined'?data[\"$1\"]:'')+'")  //转化为包括变量的字符串
                        .replace(/[\n\r]/gm,'');    //去除回车换行
            html = ["return '", html ,"';"].join('');
            console.log( html );
            return new Function('data',html);
        })(dom.innerHTML));
        if(data.length){
            for(var i=0,ar; ar=data[i]; i++){
                data[i] = parseObj(ar);
            }
        }else data[0] = def || '';
        dom.innerHTML = data.join('');
    }
};

使用方法更简单,模板这样写就可以了:

<ul id="asins">
    <li class="{class}">{title}</li>
</ul>

简单的使用:

var arr = [
    {title:'再简单不过的JS模板系统','class':'c'},
    {title:'也就一点点功能','class':'cl'},     
    {title:'够用就好,呵呵','class':'cls'},
];
Obj.setTemp('asins', arr, '<li>Null</li>'); 

我这里加了个默认值,虽然以这种方式写默认值不太喜欢,但也没想到更简单合理的方式。

更重要的一点改进是HTML中不用另外写个模板标签,要生成的代码就是模板所在的位置,更不用另外每次指定了。

如果不希望在HTML加载时看到模板代码,可以进行些改进:

模板改成这样:

<ul id="asins">
    <li style="display:none;" class="{class}">{title}</li>
</ul>

JS代码也改一点点就可以了,注意粗体部分:

这JS模板实在是太轻量了,只是个简单替换,只因为我太不喜欢不同语言的东东相互拼接。

昨天偶然看一"blog"上个有轻量的JS模板,作者的目的也是为了实现HTML代码与JS代码的分离,使得在用JS输出HTML时更方便,代码更清晰。有兴趣的可去看看 《Tempo.js : 轻量的JS模板工具类》

刚好我现做的项目有大量的HTML与JS的拼接,但作者的实现有对不适合我的代码风格,我做了些修改就运用到我的项目里,也把我修改后的代码放出来吧!写成这种形式是为了更方便的嵌入到我的项目中来,而且我也没用到更复杂的功能,最最简单的替换就够了,就像Tempo.js的作者想法:为了实现HTML代码与JS代码的分离,使得在用JS输出HTML时更方便,代码更清晰。

var Obj = {
    yyTemp: function(id, data, def){
        var dom = document.getElementById(id);
        var parseObj = dom[id] || (dom[id] = (function(html){
            html = html.replace(/([\'|\\])/gm,"\\$1")   //转义掉 \ 和 '
                        .replace(/ style="display: ?none;?"/i,'')    //去除隐藏
                        .replace(new RegExp('{([^{}]*)}','gim'), "'+(typeof data[\"$1\"] != 'undefined'?data[\"$1\"]:'')+'")  //转化为包括变量的字符串
                        .replace(/[\n\r]/gm,'');    //去除回车换行
            html = ["return '", html ,"';"].join('');
            console.log( html );
            return new Function('data',html);
        })(dom.innerHTML));
        if(data.length){
            for(var i=0,ar; ar=data[i]; i++){
                data[i] = parseObj(ar);
            }
        }else data[0] = def || '';
        dom.innerHTML = data.join('');
    }
};

之所以写成这样是因为各浏览器对HTML代码渲染后的结果不一样!FF chrome Opera IE8 IE6下都没有问题。

在性能上比你的这种方式平均慢上10ms左右吧!还能接受,这种方式最主要是不用写多条语句实现目的,另外我对给出的数据加了个简单的判断,如果没有给出会留空而不像你的这种会在HTML中出现undefined字符。猛点这里查看Demo

MOSe这词就是有病

今天我一朋友问我MOSe是什么? 答不上来,难道我又落伍了?

后发现它的意思是MOSe(Mozilla,Opera, Safari enhancement)。

我晕倒,不就是非IE浏览器嘛,又整个新名词出来干什么!

2003年,加拿大设计师、CSS Zen Garden创始人Dave Shea写了一篇备受关注的文章,阐述了如何跨越那些相互竞争的拥有不同特性的浏览器进行的设计创作的新途径,他把这个途径叫做MOSe(Mozilla,Opera, Safari enhancement)。

看这意思是说通过各浏览器自身的私有方法来实现统一的样式,就我郁闷,这些东西CSS3中都定义好了,为何整出个自己的么有属性,是觉得CSS设计人员还不够累吗?

MOSe又是个旧瓶装新“酒”,多少年来CSS设计人员都是这么写的,现整出个名词干什么?给设计人员平反吗?

给VIM添加jsLint时遇到文件路径有空格时会报错

这问题是我2010年二月份遇到的,也跑到VIM-cn上发贴求助,但无果,整个问题是这样的:

但我不喜欢把东西加到环境变量中,看到下面回复的有修改let g:jslint_command 达到目的的, 就决定使用这种方式,将jsLint下载下来后我放到了VIM程序目录,与VIM、vimfiles并列,但我发现这样使用之后一直报D:\program错误,这应该与它后面带个空格有关。

今天再次蛋痛折腾起这个问题来,终于让我想到种方法了,

  let jsl_command = substitute(g:jslint_command, 'Program Files', 'Progra~1', 'g') . ' ' . g:jslint_command_options . ' ' . current_file

呵呵,就这样,我是直接修改javascriptLint.vim实现的,不知有没有更好的方法,反正是实现了我要的目的,不管了。

另,编码如果是UTF-8会有问题,要转一下:

  if has("win32") && v:lang == 'zh_CN.utf-8'
    let jsl_command = iconv(jsl_command, 'utf-8', 'gbk')
  endif

  if has("win32") && v:lang == 'zh_CN.utf-8'
    let cmd_output = iconv(cmd_output, 'gbk', 'utf-8')
  endif

整个插件修改后的样子:

" File:         javascriptLint.vim
" Author:       Joe Stelmach (joe@zenbe.com)
" Version:      0.3a1
" Description:  javascriptLint.vim allows the JavaScript Lint (jsl) program
"               from http://www.javascriptlint.com/ to be tightly integrated
"               with vim.  The contents of a javascript file will be passed
"               through the jsl program after the file's buffer is saved.
"               Any lint warnings will be placed in the quickfix window.
"               JavaScript Lint must be installed on your system for this
"               plugin to work properly.  This page should get you started:
"               http://www.javascriptlint.com/docs/index.htm
"
"               Modifications were made by smith (nlloyds@gmail.com) to make
"               the program called from a command instead of upon saving.
"               Other minor modifcations were also made
"
" Last Modified: December 28, 2009

if !exists("jslint_command")
  let jslint_command = 'jsl'
endif

if !exists("jslint_command_options")
  let jslint_command_options = '-nofilelisting -nocontext -nosummary -nologo -process'
endif

if !exists("jslint_highlight_color")
  let jslint_highlight_color = 'DarkMagenta'
endif

" set up auto commands
" Commented out by smith
"autocmd BufWritePost,FileWritePost *.js call JavascriptLint()
"autocmd BufWinLeave * call s:MaybeClearCursorLineColor()

" set up commands
command! JavaScriptLint call JavascriptLint()
command! JavaScriptLintClear call s:ClearCursorLineColor()

" Runs the current file through javascript lint and 
" opens a quickfix window with any warnings
" TODO: Make this work with ranges
function! JavascriptLint() 
  " run javascript lint on the current file
  let current_file = shellescape(expand('%:p'))

  if has("win32")
      let g:jslint_command = substitute(g:jslint_command, 'Program Files', 'Progra~1', 'g')
  endif
  let jsl_command =  g:jslint_command . ' ' . g:jslint_command_options . ' ' . current_file
  " echo jsl_command

  if has("win32") && v:lang == 'zh_CN.utf-8'
    let jsl_command = iconv(jsl_command, 'utf-8', 'gbk')
  endif

  let cmd_output = system(jsl_command)

  if has("win32") && v:lang == 'zh_CN.utf-8'
    let cmd_output = iconv(cmd_output, 'gbk', 'utf-8')
  endif

  " if some warnings were found, we process them
  if strlen(cmd_output) > 0

    " ensure proper error format
    let s:errorformat = "%f(%l):\%m^M"

    " write quickfix errors to a temp file 
    let quickfix_tmpfile_name = tempname()
    exe "redir! > " . quickfix_tmpfile_name
      silent echon cmd_output
    redir END

    " read in the errors temp file 
    execute "silent! cfile " . quickfix_tmpfile_name

    " change the cursor line to something hard to miss 
    call s:SetCursorLineColor()

    " open the quicfix window
    botright copen
    let s:qfix_buffer = bufnr("$")

    " delete the temp file
    call delete(quickfix_tmpfile_name)

  " if no javascript warnings are found, we revert the cursorline color
  " and close the quick fix window
  else 
    call s:ClearCursorLineColor()
    if(exists("s:qfix_buffer"))
      cclose
      unlet s:qfix_buffer
    endif
  endif
endfunction

" sets the cursor line highlight color to the error highlight color 
" FIXME: This doesn't work for me
function! s:SetCursorLineColor() 
  " check for disabled cursor line
  if(!exists("g:jslint_highlight_color") || strlen(g:jslint_highlight_color) == 0) 
    return 
  endif

  call s:ClearCursorLineColor()
  let s:highlight_on = 1 

  " find the current cursor line highlight info 
  redir => l:highlight_info
    silent highlight CursorLine
  redir END

  " find the guibg property within the highlight info (if it exists)
  let l:start_index = match(l:highlight_info, "guibg")
  if(l:start_index > 0)
    let s:previous_cursor_guibg = strpart(l:highlight_info, l:start_index)

  elseif(exists("s:previous_cursor_guibg")) 
    unlet s:previous_cursor_guibg
  endif

  execute "highlight CursorLine guibg=" . g:jslint_highlight_color
endfunction

" Conditionally reverts the cursor line color based on the presence
" of the quickfix window
function! s:MaybeClearCursorLineColor()
  if(exists("s:qfix_buffer") && s:qfix_buffer == bufnr("%"))
    call s:ClearCursorLineColor()
  endif
endfunction

" Reverts the cursor line color
function! s:ClearCursorLineColor()
  " only revert if our highlight is currently enabled
  if(exists("s:highlight_on") && s:highlight_on) 
    let s:highlight_on = 0 

    " if a previous cursor guibg color was recorded, we use it
    if(exists("s:previous_cursor_guibg")) 
      execute "highlight CursorLine " . s:previous_cursor_guibg
      unlet s:previous_cursor_guibg

    " otherwise, we clear the curor line highlight entirely
    else
      highlight clear CursorLine 
    endif
  endif
endfunction

现在使用这个插件就不用在环境变量里设置了,可以在_vimrc中这样写:

let g:jslint_command = $VIM.'/jsLint/jsl.exe' 

注:我是把jsLint放到了VIM程序的同一目录下

vim插件ZenCoding一些常用的操作

相当的酷,记录一些常用的操作

安装很方便,不再像我以前使用的sparkup.vim得配置python环境了,可直接到http://github.com/mattn/zencoding-vim下载zencoding.vim文件放到vimfiles/plugin.vim/plugin目录就OK了。

接下来介绍些使用方法(Copy自LazyHack的使用zen coding for vim快速编写html代码

  • 展开缩写

输入 div>p#foo$*3>a 这样的缩写,然后按 ctrl + y + , 来展开(注意那个逗号),展开后它应该是这个样子的

 <div>
      <p id="foo1">
          <a href=""></a>
      </p>
      <p id="foo2">
          <a href=""></a>
      </p>
      <p id="foo3">
          <a href=""></a>
      </p>
  </div>
  • 多行缩写

输入如下:

test1
test2
test3

然后进入行选择模式,选中这三行按 ctrl + y + ,,接着它会提示你要使用的tag名称,TAG: 输入 ‘ul>li* 会变成如下的样子

<ul>
    <li>test1</li>
    <li>test2</li>
    <li>test3</li>
</ul>

如果是输入blockquote,那么会变成这样

  <blockquote>
      test1
      test2
      test3
  </blockquote>
  • 跳转到下一个标签编辑位置

输入ctrl + y + n 进入插入模式

  • 跳转到上一个标签编辑位置

输入ctrl + y + N 进入插入模式

  • 更新标签中图片大小

假如有以下内容

<img src="foo.png" />

光标移动到img标签上,按下ctrl + y + i 该插件会自动获取foo.png的大小并插入宽高属性 看起来像这个样子

<img src="foo.png" width="32" height="48" />
  • 切换注释

如有以下段

<div>
    hello world
</div>

光标移动到此段落,输入ctrl + y + /变成

<!-- <div>
    hello world
</div> -->

再次输入则还原

  • 生成url连接

将光标移动到一个url上,如:

http://www.google.com/

输入ctrl + y + a 它会自动获取url页面的标题并生成一个连接

<a href="http://www.google.com/"></a>

zencoding.vim更新十分频繁,大家可以关注下。

VIM官方插件地址:http://www.vim.org/scripts/script.php?script_id=2981

zencoding.vim在Github的地址:http://github.com/mattn/zencoding-vim

Zen Coding官方地址:http://code.google.com/p/zen-coding/

Zen Coding官方提供的速查手册(PDF):http://zen-coding.googlecode.com/files/ZenCodingCheatSheet.pdf

我的VIM配置文件(2010-07-30更新)

Update(2010-07-30): 今天看了下我的blog流量统计,访问量最多的就是这文章了,为对得起看文章的网友,更新下!^~^

用了这么久了,算是学习了这些配置了,放出来当做备份吧,如有像我一样喜欢VIM的也可以交流下,

vimfile目录下的所有文件都上传到空间吧!包括了所有插件、配色、字典、中文帮助等东东,blog不再提供下载了,不方便保存最新,放google codeb,可移步看看http://code.google.com/p/asins/

也对我的配置文简单的说明下吧!

  • 默认使用UTF-8的编码,当然对多语言环境也进行了配置;
  • 所有命令有明确的注释,这以成为我的习惯,方便自己也方便其人;
  • 支持Windows Linux,公司没办法得在windows下工作。Linux是我一直的向往所以我尽量做到支持这两个系统,但配置有些设置在Linux下的VIM中无效,GVIM是没问题的。
  • 字体我改用适合于编程使用的等宽字体YaHei.Consolas.1.12.ttf,这是个合成的字体,中文使用雅黑英文使用Consolas,

    "========================================================================= " DesCRiption: 适合自己使用的vimrc文件,for Linux/Windows, GUI/Console " " Last Change: 2010-07-30 17:59:37 Asins - asinsimple AT gmail DOT com " " Author: Assins - asinsimple AT gmail DOT com " Get latest vimrc from http://nootn.com/blog/Tool/22/ " " Version: 1.82 "=========================================================================

    set nocompatible " 关闭 vi 兼容模式 syntax on " 自动语法高亮 set number " 显示行号 set nocursorline " 不突出显示当前行 set ruler " 打开状态栏标尺 set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4 set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格 set tabstop=4 " 设定 tab 长度为 4 set nobackup " 覆盖文件时不备份 set autochdir " 自动切换当前目录为当前文件所在的目录 filetype plugin indent on " 开启插件 set backupcopy=yes " 设置备份时的行为为覆盖 set ignorecase smartcase " 搜索时忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感 set nowrapscan " 禁止在搜索到文件两端时重新搜索 set incsearch " 输入搜索内容时就显示搜索结果 set hlsearch " 搜索时高亮显示被找到的文本 set noerrorbells " 关闭错误信息响铃 set novisualbell " 关闭使用可视响铃代替呼叫 set t_vb= " 置空错误铃声的终端代码 " set showmatch " 插入括号时,短暂地跳转到匹配的对应括号 " set matchtime=2 " 短暂跳转到匹配括号的时间 set magic " 设置魔术 set hidden " 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存 set guioptions-=T " 隐藏工具栏 set guioptions-=m " 隐藏菜单栏 set smartindent " 开启新行时使用智能自动缩进 set backspace=indent,eol,start " 不设定在插入状态无法用退格键和 Delete 键删除回车符 set cmdheight=1 " 设定命令行的行数为 1 set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏) set foldenable " 开始折叠 set foldmethod=syntax " 设置语法折叠 set foldcolumn=0 " 设置折叠区域的宽度 setlocal foldlevel=1 " 设置折叠层数为 " set foldclose=all " 设置为自动关闭折叠
    colorscheme colorzone " 设定配色方案 " colorscheme molokai " 设定配色方案 set statusline=\ %<%F[%1%M%%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ " 设置在状态行显示的信息

    " 显示Tab符 set listchars=tab:|\ ,trail:.,extends:>,precedes:< if has("autocmd") autocmd filetype javascript,php,python set list endif

    " 设置字体 以及中文支持 set guifont=YaHei\ Consolas\ Hybrid:h12 " set linespace=0

    " set guifont=Consolas:h12

    " return OS type, eg: windows, or linux, mac, et.st.. function! MySys() if has("win16") || has("win32") || has("win64") || has("win95") return "windows" elseif has("unix") return "linux" endif endfunction

    " 用户目录变量$VIMFILES if MySys() == "windows" let $VIMFILES = $VIM.'/vimfiles' elseif MySys() == "linux" let $VIMFILES = $HOME.'/.vim' endif

    " 设定doc文档目录 let helptags=$VIMFILES.'/doc'

    " 配置多语言环境 if has("multi_byte") " UTF-8 编码 set encoding=utf-8 set termencoding=utf-8 set formatoptions+=mM set fencs=utf-8,gbk

    if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
        set ambiwidth=double
    endif
    
    if has("win32")
        source $VIMRUNTIME/delmenu.vim
        source $VIMRUNTIME/menu.vim
        language messages zh_CN.utf-8
    endif
    

    else echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte" endif

    " Buffers操作快捷方式! nnoremap :bnext nnoremap :bprevious

    " Tab操作快捷方式! nnoremap :tabnext nnoremap :tabprev

    "关于tab的快捷键 " map tn :tabnext " map tp :tabprevious " map td :tabnew . " map te :tabedit " map tc :tabclose

    "窗口分割时,进行切换的按键热键需要连接两次,比如从下方窗口移动 "光标到上方窗口,需要k,非常麻烦,现在重映射为,切换的 "时候会变得非常方便. nnoremap h nnoremap j nnoremap k nnoremap l

    "一些不错的映射转换语法(如果在一个文件中混合了不同语言时有用) nnoremap 1 :set filetype=xhtml nnoremap 2 :set filetype=css nnoremap 3 :set filetype=javascript nnoremap 4 :set filetype=php

    " set fileformats=unix,dos,mac " nmap fd :se fileformat=dos " nmap fu :se fileformat=unix

    " use Ctrl+[l|n|p|cc] to list|next|previous|jump to count the result " map l :cl " map n :cn " map p :cp " map c :cc

    " 让 Tohtml 产生有 CSS 语法的 html " syntax/2html.vim,可以用:runtime! syntax/2html.vim let html_use_css=1

    " Python 文件的一般设置,比如不要 tab 等 autocmd FileType python set tabstop=4 shiftwidth=4 expandtab autocmd FileType python map :!python %

    " 选中状态下 Ctrl+c 复制 vmap "+y

    " 打开javascript折叠 let b:javascript_fold=1 " 打开javascript对dom、html和css的支持 let javascript_enable_domhtmlcss=1 " 设置字典 ~/.vim/dict/文件的路径 autocmd filetype javascript set dictionary=$VIMFILES/dict/javascript.dict autocmd filetype css set dictionary=$VIMFILES/dict/css.dict autocmd filetype php set dictionary=$VIMFILES/dict/php.dict

    "----------------------------------------------------------------- " plugin - bufexplorer.vim Buffers切换 " \be 全屏方式查看全部打开的文件列表 " \bv 左右方式查看 \bs 上下方式查看 "-----------------------------------------------------------------

    "----------------------------------------------------------------- " plugin - taglist.vim 查看函数列表,需要ctags程序 " F4 打开隐藏taglist窗口 "----------------------------------------------------------------- if MySys() == "windows" " 设定windows系统中ctags程序的位置 let Tlist_Ctags_Cmd = '"'.$VIMRUNTIME.'/ctags.exe"' elseif MySys() == "linux" " 设定windows系统中ctags程序的位置 let Tlist_Ctags_Cmd = '/usr/bin/ctags' endif nnoremap :TlistToggle let Tlist_Show_One_File = 1 " 不同时显示多个文件的tag,只显示当前文件的 let Tlist_Exit_OnlyWindow = 1 " 如果taglist窗口是最后一个窗口,则退出vim let Tlist_Use_Right_Window = 1 " 在右侧窗口中显示taglist窗口 let Tlist_File_Fold_Auto_Close=1 " 自动折叠当前非编辑文件的方法列表 let Tlist_Auto_Open = 0 let Tlist_Auto_Update = 1 let Tlist_Hightlight_Tag_On_BufEnter = 1 let Tlist_Enable_Fold_Column = 0 let Tlist_Process_File_Always = 1 let Tlist_Display_Prototype = 0 let Tlist_Compact_Format = 1

    "----------------------------------------------------------------- " plugin - mark.vim 给各种tags标记不同的颜色,便于观看调式的插件。 " \m mark or unmark the word under (or before) the cursor " \r manually input a regular expression. 用于搜索. " \n clear this mark (i.e. the mark under the cursor), or clear all highlighted marks . " * 当前MarkWord的下一个 # 当前MarkWord的上一个 " \/ 所有MarkWords的下一个 \? 所有MarkWords的上一个 "-----------------------------------------------------------------

    "----------------------------------------------------------------- " plugin - NERD_tree.vim 以树状方式浏览系统中的文件和目录 " :ERDtree 打开NERD_tree :NERDtreeClose 关闭NERD_tree " o 打开关闭文件或者目录 t 在标签页中打开 " T 在后台标签页中打开 ! 执行此文件 " p 到上层目录 P 到根目录 " K 到第一个节点 J 到最后一个节点 " u 打开上层目录 m 显示文件系统菜单(添加、删除、移动操作) " r 递归刷新当前目录 R 递归刷新当前根目录 "----------------------------------------------------------------- " F3 NERDTree 切换 map :NERDTreeToggle imap :NERDTreeToggle

    "----------------------------------------------------------------- " plugin - NERD_commenter.vim 注释代码用的, " [count],cc 光标以下count行逐行添加注释(7,cc) " [count],cu 光标以下count行逐行取消注释(7,cu) " [count],cm 光标以下count行尝试添加块注释(7,cm) " ,cA 在行尾插入 /* */,并且进入插入模式。 这个命令方便写注释。 " 注:count参数可选,无则默认为选中行或当前行 "----------------------------------------------------------------- let NERDSpaceDelims=1 " 让注释符与语句之间留一个空格 let NERDCompactSexyComs=1 " 多行注释时样子更好看

    "----------------------------------------------------------------- " plugin - DoxygenToolkit.vim 由注释生成文档,并且能够快速生成函数标准注释 "----------------------------------------------------------------- let g:DoxygenToolkit_authorName="Asins - asinsimple AT gmail DOT com" let g:DoxygenToolkit_briefTag_funcName="yes" map da :DoxAuthor map df :Dox map db :DoxBlock map dc a /* */

    "----------------------------------------------------------------- " plugin – ZenCoding.vim 很酷的插件,HTML代码生成 " 插件最新版:http://github.com/mattn/zencoding-vim " 常用命令可看:http://nootn.com/blog/Tool/23/ "-----------------------------------------------------------------

    "----------------------------------------------------------------- " plugin – checksyntax.vim JavaScript常见语法错误检查 " 默认快捷方式为 F5 "----------------------------------------------------------------- let g:checksyntax_auto = 0 " 不自动检查

    "----------------------------------------------------------------- " plugin - NeoComplCache.vim 自动补全插件 "----------------------------------------------------------------- " Use neocomplcache. let g:neocomplcache_enable_at_startup = 1 " Use smartcase. let g:neocomplcache_enable_smart_case = 1 " Use camel case completion. let g:neocomplcache_enable_camel_case_completion = 1 " Use underbar completion. let g:neocomplcache_enable_underbar_completion = 1 " Set minimum syntax keyword length. let g:neocomplcache_min_syntax_length = 3 let g:neocomplcache_lock_buffer_name_pattern = '*ku*'

    " Define dictionary. let g:neocomplcache_dictionary_filetype_lists = { \ 'default' : '', \ 'css' : $VIMFILES.'/dict/css.dict', \ 'php' : $VIMFILES.'/dict/php.dict', \ 'javascript' : $VIMFILES.'/dict/javascript.dict' \ }

    " Define keyword. if !exists('g:neocomplcache_keyword_patterns') let g:neocomplcache_keyword_patterns = {} endif let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

    " Plugin key-mappings. imap (neocomplcache_snippets_expand) smap (neocomplcache_snippets_expand) inoremap neocomplcache#undo_completion() inoremap neocomplcache#complete_common_string()

    " Recommended key-mappings. " : completion. inoremap pumvisible() ? "\" : "\" " , : close popup and delete backword char. inoremap pumvisible() ? neocomplcache#close_popup()."\" : "\" inoremap pumvisible() ? neocomplcache#close_popup()."\" : "\" inoremap neocomplcache#close_popup() inoremap neocomplcache#cancel_popup()

    " AutoComplPop like behavior. "let g:neocomplcache_enable_auto_select = 1 "inoremap (pumvisible() ? "\":'') . (&indentexpr != '' ? "\\X\":"\") "inoremap pumvisible() ? neocomplcache#cancel_popup()."\" : "\" "inoremap pumvisible() ? neocomplcache#cancel_popup()."\" : "\"

    "----------------------------------------------------------------- " plugin - matchit.vim 对%命令进行扩展使得能在嵌套标签和语句之间跳转 " % 正向匹配 g% 反向匹配 " [% 定位块首 ]% 定位块尾 "-----------------------------------------------------------------

    "----------------------------------------------------------------- " plugin – a.vim "-----------------------------------------------------------------

    " web文件快速访问 " function! BrowseWebPage() " let filepath=substitute(fnamemodify(bufname("%"), ":p"), 'D:\MyWeb\', "http://localhost/", "g") " let filepath=substitute(filepath, "\", "/", "g") " silent execute "!start \"d:\Program Files\Mozilla Firefox\firefox.exe\" ". filepath ." -install-global-extension" " endfunction " map :call BrowseWebPage()