Kate Vi Input Mode – GSoC 2011

I want to introduce you my GSoC-2011 project. I was working on improvement the vi input mode for the Kate part.

There are a lot of improvements for normal mode. Now it’s able to use jump list by pressing ctrl-i/ctrl-o in normal mode like in vim. And now not only registers but also marks, and jumps stored in the config of the session. H, M and L commands moves cursor to the first(Home), Middle and Last line of the screen. To go to the any percent of the document you can use the % command by typing the number of percent(1-100) before it. gk and gj motions will make you able to go visual(display) lines up and down. It’s useful when you using line wrap.

You can split the screen vertically and horizontally by ctrl-s and ctrl-v shortcuts and move around them in different directions using ctrl-w{h,j,k,l,w} or also ctrl-w{←,↑,↓,→}.

In insert mode added commands ctrl-r+[register] to insert the contents of a register and ctrl-o to switch to the normal mode only for a one command and automatically get back to insert. The ctrl-a, ctrl-x command now increase and decrease the negative numbers too.

There are also some new command-line features. Now you can use the marks for a command ranges. It’s possible to add and subtract line numbers in the ranges many times. For example command :.+3d will delete the third line after current position and the command :’a,’b-1y will yank the line-wise range between the line of mark ‘a’ and the one line before the line of ‘b‘ mark.

Also there a some new basic vim commands:

  • :d or :delete – delete range;
  • :c or :change – change range;
  • :j – join all the lines in range;
  • :> – indent range;
  • :< – unindent range;
  • :y or :yank – yank range;
  • :ma or :mark or :k – set mark;
  • :bn – switch to next buffer(document);
  • :bp – switch to previous buffer(document);
  • :bf – to first buffer;
  • :bl – to last buffer;
  • :b [N] or :buffer [N] – to Nth buffer

Text objects are also improved and fixed. There are new objects: ( a{ , i{ , a< , i< , a` , i` ). And now they normally works with nested objects. So for now the i( object (for position of multiply symbol *) will be “(1*2/(2+3)–4)” instead of “(1*2/(2+3)–4)”. Some of the objects like (),{},[],<> works with several lines.

Visual mode now is integrated with mouse, so the mouse dragging starts the visual mode. All kind of Kate-way selection is also starts the visual mode. For example if you use “Select all” menu line or shortcut ctrl-a(by default) this will starts visual mode with the selected text and waits you for a command to execute :) . One point mouse click will exit the visual mode. Kate selection and vi mode selection is actually the same thing now. So you can, say, to select a bloc by using the Visual Block mode (ctrl-v), to do a context menu on them and to copy them to a clipboard :). When you exit visual mode the ‘< and ‘> marks have a start and end position of selection. It useful when you want to execute some command line command on the selected text. Just press the “:” when you select something and it automatically fill the command line with “‘<,’>” to have a quick access to selected area.

Vi marks and Kate bookmarks are integrated too. If you set the mark then this line becomes bookmarked by Kate. And vice versa: if you set a Kate’s bookmark and there no vi marks on this like vi mode sets the vim mark on this line and zero column, and shows you what letter for this mark is used.You can see the position of all vi marks in the bookmark menu in the menu bar or also in the context menu.

I hope this features will make you feel even more comfortable while using Kate. You can try it now in the git version of Kate.
Any notice or bug report are welcome !

13 thoughts on “Kate Vi Input Mode – GSoC 2011”

  1. How did you implement the ctrl+w+ functionality to switch the active view? You can write another blog about it… You should blog much more! :)

  2. Great ! Many thanks for your work :)

    I like how you explains how things works (not technically but in the usage), it’s much easier for a vi-mode novice this way. It could be great if this kind of explanations could integrate the “VI Mode” section of the site, a kind of wiki instead of a long list of commands !

  3. Greaattt !!! Your work is excellent.
    Thank you very mcuh to have implemented all of this awesome features.

    Cheers
    Francois

  4. awsome!! ctrl-v in Kate – thank you so much. That was probably my most missed feature, I shall try it asap.
    Another thing I realized in Kate, I didn’t find a way to navigate between tabs in Kate (or KDevelop which I guess uses the same code). Something along the lines of: gt, gT, g0 and g$. I don’t know whether it’s just me with a smallish screen using tabs but I find myself using these quite often and no shortcut interrupts the workflow once you’re in keyboard mode.

    Personally I have been experimenting a bit on plasmoids applets like activity bar or task bar to introduce screen/vim like mnemonic shortcuts for basic navigation. IMO once you are in vim like keyboard mode – why leave it? Didn’t get very far yet since I’m just starting with qt so I think have to check your code to learn something :-)

    1. Visual Block mode(ctrl-v) is already implemented by Erlend Hamberg and it is available in the current Kate release. See this post:
      http://hamberg.no/erlend/2011/01/19/visual-block-mode-for-kate%E2%80%99s-vi-mode/

      I thought about tabs but Kate has no vim-like tabs. Maybe Kate guru will correct me?
      In vim each tab page holds one or more views(windows). And you can switch between the collection of this windows. It is more like Kate’s sessions than a Kate tabs. But Kate’s tabs is like a vim-buffers. I think you mean this.
      And I think it is good idea to duplicate already implemented :bn, :bp,.. command-line commands by gt, gT, etc, isn’t it?

  5. Wonderful !
    ctrl+V and mouse selection were my most wanted features.
    Next on my wish list would be the (rather simple I think) ctrl+D and ctrl+U in normal mode (scroll half-page)

    Thanks a lot for your hard work !

  6. I’m also interested in whether kate will be embedable by kmail – thereby finally once again being able to compose emails in vi-mode; is this something that will possible, or is something holding it back?

    Also – I looked at the vi-mode features that kate currently has, but I missed one feature I use alot: jumping to line numbers via : … is that available with kates vi-mode?

    Thanks a ton for all the effort in this, very much appreciated!

    Beers!

  7. The ‘jump to line number’ ex command didn’t show up as I intended.

    :1

    or

    :24

    for instance, will jump to the 1st and 24th line

    Does kate-vi-mode support that?

Leave a Reply