Xcode 13 vim mode documentation?

Is there any documentation on which commands are supported for vim mode now? I know there's the help bar (though I haven't seen it appear since yesterday...). Is there vimrc support, etc...?

  • Yah, same question here. I'm so excited to to see what a builtin support for vim would be like, and how can users do the basic vimrc stuff as well as access XCode command to map keys to Xcode functions

    Thanks

  • to enable Preferences → Text Editing → Editing → Enable Vim key bindings.

  • With Xcode 13 beta 3, the enabling seems to have moved to Editor -> Vim Mode

Replies

We are working on publishing an article about Vim key bindings. Until the official article is out, here is the brief list of Vim commands supported in Xcode 13 beta.

Normal Mode Commands

  • Motion Commands: (h, ←), (l, →), (⌫, ⌃h), <space>, (0, ↖), ($, ↘), (g0, g↖), (g$, g↘), ^, g_, g^, F{character}, f{character}, T{character}, t{character}, ;, <comma>, (k, ⌃p, ↑), (j, ⌃j, ⌃n, ↓), (gk, g↑), (gj, g↓), _, -, (+, ↩, ⌃m), (gg, ⌃↖), G, ⌃↘, %, (b, ⇧←), (w, ⇧→), (B, ⌃←), (W, ⌃→), ge, e, gE, E, {, }, %, H, M, L, ⇥, ⇧⇤
  • Scrolling Commands: ^y, ^e, ^u, ^d, (⌃b, ⇧↑, ⇞), (⌃f, ⇧↓, ⇟), z↩, zt, zz, z., z-, zb
  • Insert and Replace Commands: a, A, (i, <insert>), I, o, O
  • Deleting Text Commands: ["x]X, (["x]x, ["x]⌦), ["x]dd, ["x]d{motion}, D, J, gJ, ["x]c{motion}, (["x]cc, ["x]S), ["x]C, ["x]s
  • Simple Changes Commands: <<, >>, ~
  • Copying and Moving Text Commands: ["x]yy, ["x]y{motion}, ["x]Y, ["x]p , ["x]P
  • Undo and Redo Commands: (u, <undo>), ⌃r
  • Visual Commands: v, V, ^v
  • Search Commands: ?, /, E, , gE, g, n, N

Visual Mode Commands

  • Motion Commands: ;, <comma>, ⇥, ⇧⇤, (h, ←), (l, →), (⌫, ⌃h), <space>, (0, ↖), ($, ↘), (g0, g↖), (g$, g↘), ^, g_, g^, F{character}, f{character}, t{character}, T{character}, (k, ⌃p, ↑), (j, ⌃j, ⌃n, ↓), (gk, g↑), (gj, g↓), (b, ⇧←), (w, ⇧→), (B, ⌃←), (W, ⌃→), ge, e, gE, E, H, M, L
  • Text Object Selection Commands: aw, iw, aW, iW, (a[, a]), (i[, i]), (a(, a), ab), (i(, i), ib), (a<, a>), (i<, i>), (a{, a}, a😎 , (i{, i}, i😎 , a", i", a', i', a, i
  • Deleting Text Commands: (["x]x, ["x]d, ["x]⌦), (["x]c, ["x]s)
  • Copying and Moving Text Commands: ["x]y, ["x]Y
  • Visual Commands: v, V, ^v, o
  • Search Commands: n, N, #, , g#, g

Insert Mode Commands

  • Insert and Replace Commands: ^r{register}
  • honestly, awesome work ❤️. Any planned support for vimrc, or away to remap stuff?

  • I'd like to have Developer Tools Engineer to add the below command.

    Normal Mode Commands

    Insert and Replace Commands: r(replace one character)
  • I just tried beta1 vim mode, it seems that V/^v and r/R command not working for now?

vi support is a breath of fresh air in Xcode 13 -- thank you for the update!

I have to train my fingers on a few things (doesn't do any good to type ":w" reflexively now), but there are two key bindings I find I miss a little: to repeat the last command and "m" for marking.

I can understand why the mark command isn't present and there are probably better ways to do what I routinely use it for anyway. But adding the command would be much appreciated if you're taking feedback. 😎

Eric

  • Second for this! Mark is the main way I move blocks of code around -- "ma" to start a block, and then go to the end, use a "d'a" and then "p" to put it in its new location. Ditto for repeating the last command - great for making repetitive renaming changes, for example. Also, huge thanks for adding this - have missed it ever since the vim plugin stopped being supported.

  • Oh, and the "r" command, please! I know I should go back to Xcode 12 for "real" work, but I just can't stop using vim mode 😃

  • Marks exist in the current emacs style Xcode text keybindings, would hope that it would be a good starting point to implement it for vim.

Sorry -- looks like the editor stripped out the text <period> before "to repeat the last command" and in the middle of "adding the command" in my prior message.

  • Yes, I'm really missing that one as well.

Add a Comment

This is great. I've noticed that some visual modes aren't implemented, in particular visual block mode and visual line mode.

  • Visual line mode works for me, but visual block mode would be nice.

  • visual block? the multiple cursors you mean? the ctrl + v? Oh man! YES on that one! I miss it very much! especially for editing constraints!

Add a Comment

ignore - moved to comment on other answer

Putting in a vote for gd, to jump to definition ❤️

Add a Comment

Delighted to finally have vi functionality and thanks for adding it because it is the one thing I hated about Xcode, but unfortunately it does still need a bit of work on some features.

There also appears to be a fault with "d", because "dw" should delete to the end of the current word, but it seems to delete the whole line?

One hugely important feature that appears to be missing is the ability to press "." to repeat the last action.

I agree with other posters that "m" should be there.

  • Just to update my comment on "dw" it appears that if you use "dw" to delete the last word on a line it deletes the whole line, but more generally appears to work.

  • Also "dd" which should delete a line is unable to delete the last line of a file.

  • Also if you do anything to edit the last line of the file it automatically creates another empty line below it, which might be why you can't delete the last line of the file?

Wishing to update my comment above, rather than leave it as a sub-posting that might be missed:

If you use dw to deletes the last word on a line (with no punctuation following it) then it will delete the whole of that line and the line below it.

Also if you search using / and find a word but then step back before that word when you press n it skips the word.

For example create the line:

my big test test

Search for the word test using /test and the first time it might take you to the first or second occurrence of the word "test", but if you then move the pointer back to the start of the line (or even further up the document) and then press n it moves the pointer to the start of the second occurrence of "test" not the first. In my tests pressing 'n' always seems to skip the first occurrence and jump to the second, but then if you press n again it will loop round to the first occurrence.

Is there any plan to allow customizing the keybindings?

Also agree that this is an awesome update. My wish list:

  • vimrc to allow custom keybindings for insert mode escape sequences and pane naviagtion
  • gd
  • dot operator
  • Goto Line number command + visual mode highlight

Thank you to all involved!

  • imap jj <Esc>

    Edit: Seems to be its own thread with plenty of up-votes for that one

Add a Comment

The missing feature I want the most is support for the period key to repeat the last command. For example, I frequently execute something like "cwfoo" to change the word under the cursor to "foo". Then I want to move somewhere else in the file and press "." to repeat that command.

Is vim mode still only available in the Xcode Beta? I can't find the mentioned setting in Xcode 13.1.

  • In the menu bar, tap Editor, then at the bottom there's Vim Mode.

Add a Comment

In Xcode 13.1 Vim Mode has been moved to Xcode's menu: "Editor" -> "Vim Mode"

  • This comment should be at the top. I've spent more than 30 minutes trying to find it because of all the outdated information in this thread and other online resources.

Add a Comment

from time to time it's gone from menu so i can't turn it off or on

command mode would be great :-)