[ Content | Sidebar ]

Posts tagged vim

vim:上一个光标位置

当年好菜啊,Ctrl-o嘛,哈哈~
———————————————-
额,搜啊搜没结果,还是看文档自己搞

ctrl + alt + left 上一个光标位置
ctrl + alt + right 下一个光标位置

刚写完,bug未知

 
"上一个光标位置
command -nargs=0 GotoPreviousPos :call GotoPreviousPos()
 
function GotoPreviousPos()
    if exists( "b:blue_previous_pos" ) && len( b:blue_previous_pos ) > 1 && b:blue_current_pos >= 0
        let b:blue_current_pos = b:blue_current_pos - 1
        call setpos( "." , b:blue_previous_pos[ b:blue_current_pos ] )
    endif
endfunction
 
"下一个光标位置
 
command -nargs=0 GotoNextPos :call GotoNextPos()
 
function GotoNextPos()
    if exists( "b:blue_previous_pos" ) && len( b:blue_previous_pos ) > b:blue_current_pos + 1
        let b:blue_current_pos = b:blue_current_pos + 1
        call setpos( "." , b:blue_previous_pos[ b:blue_current_pos ] )
    endif
endfunction
 
"记录光标位置
 
function RecordPreviousPos()
 
    let s:pos =  getpos(".")
 
    if !exists( "b:blue_previous_pos" )
       let b:blue_previous_pos = []
       let b:blue_current_pos = 0
    endif
 
    if ( len( b:blue_previous_pos ) > 500 )
        unlet b:blue_previous_pos[0]
    endif
 
    if len( b:blue_previous_pos ) > 0 && b:blue_current_pos != len( b:blue_previous_pos ) - 1
        call remove( b:blue_previous_pos , -1 )
    endif
 
    call add( b:blue_previous_pos , s:pos )
    let b:blue_current_pos = len( b:blue_previous_pos ) - 1
 
endfunction
 
autocmd CursorMovedI * call RecordPreviousPos()
 
:imap <C-A-Left> <Esc>:GotoPreviousPos<CR>i
:imap <C-A-Right> <Esc>:GotoNextPos<CR>i
:map <C-A-Left> :GotoPreviousPos<CR>
:map <C-A-Right> :GotoNextPos<CR>
Copy Code 

换用vim

在aptana崩溃了几次之后,偶决定换个稳定又容易上手的编辑器-vim

嗯嗯,用了两天,感觉灰常强大,绝对是懒人利器~

加了几个简单的自定义命令:

快速TortoiseSVN命令

"使用这几个快捷命令的前提是win的环境变量的path包含了TortoiseSVN的bin目录
 
"diff
command -nargs=0 Svndiff :call Svndiff()
function Svndiff()
   silent execute '!TortoiseProc.exe /command:diff /path:' . expand('%:p')
endfunction
 
"commit
command -nargs=1 Svncommit :call Svncommit(<f-args>)
function Svncommit(msg)
   silent execute '!TortoiseProc.exe /command:commit /path:' . expand('%:p') . ' /logmsg:' . iconv(a:msg, &enc, "chinese")
endfunction
 
"update
command -nargs=0 Svnupdate :call Svnupdate()
function Svnupdate()
   silent execute '!TortoiseProc.exe /command:update /path:' . expand('%:p')
endfunction
 
command -nargs=0 Svnlog :call Svnlog()
function Svnlog()
   silent execute '!TortoiseProc.exe /command:log /path:' . expand('%:p')
endfunction
Copy Code 

由于编辑的文件一般都在同一个目录,所以加了一个速得函数

command -nargs=1 Get :call Get(<f-args>)
function Get(f)
   exe ':tabnew d:\xxxx\xxx\xxx\' . a:f
endfunction
Copy Code 

恩,继续学习