Actually,simplicity is not simple

一组能让我爽出内伤的 Vim motion

今天有人在群里说VIM的motionn特性,后去搜索了下,顿时让我爽得想哭啊,这就不是我一直所寻找的嘛!

对于天天写HTML的我来说命令vitvatvi"真的太有用了,尤其vi"编辑属性就别太爽,以前一直是移动到属性区域按i后再疯狂按删除键。

用vim这么长时间,现看到下边几句,对vim的认识提高一个台阶。呵呵~~

以下是选择区域内的内容:

ci[ 删除一对 [] 中的所有字符并进入插入模式
ci( 删除一对 () 中的所有字符并进入插入模式
ci< 删除一对 <> 中的所有字符并进入插入模式
ci{ 删除一对 {} 中的所有字符并进入插入模式
cit 删除一对 HTML/XML 的标签内部的所有字符并进入插入模式
ci” ci’ ci` 删除一对引号字符 (” 或 ‘ 或 `) 中所有字符并进入插入模式

注:如果想一起删除区域边界可把ciX中的i换成a;如果只是想选择这些区域可将ciX中的c改为v

360,你又成为新一个3721了吗?

别的不管,用半威胁的手段让用户开启你的功能无防;捆绑你的浏览器、保险箱、网页在线游戏、卸载竞争对手的软件等等。

这些我都忍了,但为什么每次重启360都自动启动,使用你的开机启动管理工具删除了360的自动启动功能,为何还会启动?你给我解释一下,是你的软件是废品还是说你这360已经是打着安全慌子的3721?

你和金山的那点事我不管,也没心情去管,但有一点:别拿我的机器当战场。再让我看到那些恶心的提示金山XXX的窗口我首先把你这软件给XXX掉。

汉化了下SQLyog Ultimate 8.32正式版

说实话SQLyog不好汉化,居多的资源,光非标部分ASCII、Unicode、UTF-8字符串都有,而且汉化很容易出bug。对ASCII的字符依然不知如何进行汉化,我直接写入汉字在运行后就会是乱码,这次我对Unicode、UTF-8进行了独立汉化,在汉化8.12版时的很多问题都解决了。所以这次汉化率会比上次高些,但仍然不是完全,我尽我最大努力了。

这个版本同样没有汉化完全,对非标字符的汉化还是很棘手,这次发现Athena-A能在译文比原字符长时使用挪位,但我只会使用“超写”的功能,而且当可用的空白位不够时同样不知如何处理,无奈!

快捷键对照表那块Athena-A无法找到,使用eXeScope到是能进行汉化,原本这一块已经汉化完了的,但在一次操作时覆盖掉了,所以就不再重复一次了,这次仍然是英文的。^0^ God!!!

来张汉化后的图

SQLyog Ultimate 8.32正式汉化版

这次SQLyog更改了注册算法,以前的注册机没用了,但我找到个可用的注册码,也分享出来吧!

Name: Any
Registration Code: 26f359fc-e3f6-4727-8af1-72a1a4a0819d

差点忘了放汉化版的下载地址了,猛点这里 。地址已修改,不再放在自己的空间里,写博文时就把软件提交给绿色联盟了,原意是等收录了再改过去,但他们瞧不上我的分享一直不给收录,那算了放网络U盘里吧!一样可以下载。

2010年5月27日更新:收到网友邮箱说在XP下有点问题,小修正了下,下载地址在这里猛点这里。(感谢守护幸福的反馈) 很早了,睡觉去了!早安 ^..^

Update(2010-08-26):今天有网友反应下载地址不能用了,这也很正常了,115网盘的共享有效期只有30天,今天再次共享下,有需要的朋友可以去下载。有朋友说SQLyog 8.6正式版出来了让我赶紧去汉化,但我最近没多少空余的时间去做汉化工作,再者我手上也没有英文正式版的文件,找正式版的原文件也是很费劲的,如有朋友找到了可以发给我,我争取抽点时间汉化出来。

给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