给xcode插上vim的翅膀

From : http://blog.cnrainbird.com/index.php/2012/12/11/gei_xcode_cha_shang_vim_de_chi_bang/

 

用eclipse的同学开始使用xcode的时候总会问:上下两行交换位置用什么快捷键,选中{怎么自动跳到}。好吧,上下两行交换交换位置在4.x的xcode里确实是有快捷键的:option+command+[向上移;option+command+]向下移。但是这个{}之间的来回跳转我确实没研究出来。于是想着vim里有这样的快捷键,于是google:xcode+vim竟然有个叫作xvim的神器,于是赶紧装了。下面是在这个环境下编程了三四天的感受:

1.作为vim党,用这个插件确实很享受,尤其是习惯了h,j,k,l这些键上下移动

2.{}来回跳转解决了,在大量if,else的时候很有用哟。

3.可以直接直接跳转到哪些行,yy,dd自然不在话下。另外上下两行交换位置也不用按那么多键了,直接ddp搞定。

4.习惯了在vim里输入完东西,然后就:w保存。要知道xcode每次编译运行都会自动保存代码的。so,正在逐渐的适应:run,相当于command+b哟。

唯一不爽的:

选择多行,command+x剪切的时候会崩溃,这问题出现过两次了,还没空看代码解决Bug,不过遇到这种情况用vim的快捷键就好了。

另外就是目前还不支持:20,30d这种指令,准备有空了仔细看下代码给加上。

 

最后说下安装方法:

1.下载安装包

2.双击安装

3.重启xcode

 

然后就是have fun了~

 

Feature List

We try to keep this up to date, but sometimes implementation can get ahead of documentation. If a command is missing, just try it in XVim first - it might already be there!

If you've tried a command and it really is missing, feel free to create an issue and a friendly contributor will pick it up eventually.

Motion

b, B, f, F, gg, G, h, j, k, l, w, W, t, T, 0, $, ^, %, +, -, {, }, (, ), n, N, ', `, M, H, L

Comma and semicolon are supported. Toggle inclusive/exclusive by v is supported.

Mark

File-local marks are supported. Global marks are not yet supported.

The '.' mark (last insertion point) is supported. gi (insert mode at last insertion point) is supported.

Scroll

C-d, C-f, C-e, C-u, C-b, C-y, zz, zb, zt

Jumps

C-o, C-i, gd

If you want to open the file under the cursor you can use 'gd' instead of 'gf' in XVim environment.

Insert

a, A, i, I, o, O

Yank, put and change

d, dd, D, y, yy, Y, c, cc, C, r, s, x, X

Line join

J

Shift block

Normal mode: >, >>, <, <<

Visual mode: >, <

Case change operations

Normal mode: ~, gu, gU, g~

Visual mode: u, U, ~, gu, gU

Undo

u, C-r

Visual

v, V

Ctrl-v is not supported now. (v, V in visual mode to toggle or escape from visual mode is supported)

Visual block mode is currently not supported.

Window manipulation

InputOperation
C-w nAdd new assistant editor
C-w qDelete one assistant editor
C-w sAdd new assistant editor horizontally
C-w vAdd new assistant editor vertically
C-w h,j,k,lMove focus between editors

Search and Replace

/, ?, #, *, g*, g#, :s, n, N

Regex search is supported using the ICU regex format.

Substitution does not work as Vim does. When you input command following

:%s/xxxx/yyyy/

XVim does replace the first occurence of xxxx IN THE FILE (not each line ). If you want to replace all the occurence of xxxx with yyyy in the file you can specify

:%s/xxxx/yyyy/g

Currently replacing first occurence of xxxx with yyyy each line is not available

Insert mode commands

C-y, C-e

Print status commands

C-g

Text Object

ib, iB, i(, i), i{, i}, i[, i], i>, i<, i", i', iw, iW ab, aB, a(, a), a{, a}, a[, a], a>, a<, a", a', aw, aW

Recording

q, @

Dot command

The dot command ('.') is supported.

Ex commands

CommandNote
:w[rite] 
:wq 
:q[uit] 
:s[ubstitute] 
:setSee Options for supported variables
:mapMaps globally across XVim, in all modes
:nmapMaps normal mode
:vmapMaps visual mode
:imapMaps insert mode
:omapMaps operator pending mode

XVim original commands

CommandNote
:runInvoke Xcode's 'run' command
:makeInvoke Xcode's 'build' command
:xhelpShow quick help for current insertion point
:xccmdInvoke arbitrary command in Xcode's actions in its menu. Takes one argument as its action to invoke. Actions here are available.
:nissueInvoke "jump to next issue". ":ni" does the samse.
:pissueInvoke "jump to previous issue". ":pi" does the same.
:ncounterpartInvoke "jump to next counterpart". ":nc" does the same.
:pcounterpartInvoke "jump to previous counterpart". ":pc" does the same.

Options

CommandNote
[no]ignorecase 
[no]wrap 
[no]wrapscan 
[no]errorbells 
[no]incsearch 
[no]gdefault 
[no]smartcase 
guioptionsSee below
timeoutlenThe time in milliseconds that is waited for mapped key sequence to complete (default 1000)
laststatus0 or 1 : status line is hidden, 2 : status line is displayed (default 2)
[no]pasteboardWhether yank/delete/pull uses the standard clipboard

pasteboard

guioptions

A limited subset of Vim options is implemented.

OptionEffect
rShow vertical scrollbar
bShow horizontal scrollbar

These changes only take effect on startup, meaning this option is only effective if used from within your .xvimrc.

Key mapping

XVim supports five map commands: map, nmap, vmap, imap, omap. A map command can change one or more keystrokes into one or more key strokes.

Note: The default timeout value for multi-key mapping completion is 1 seconds (1000 milliseconds). You can change it using 'timeoutlen' option.

Examples:

nmap n e
imap ' <Esc>
nmap u 5jiInsert some text<Esc>
nmap ,w :w<cr>

.xvimrc

At startup XVim looks for ~/.xvimrc. Each line in this file is executed as an ex command. This allows you to configure mappings and options.

Example:

set ignorecase
set wrapscan
set guioptions=r
nmap n e

Known problems

See XVim issue page.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值