Thursday, 24 March 2011

Single key split line in vim command mode

I've spent many time typing i<enter><esc> just for splitting line when my line become more than 80 symbols.

In vim there is no simple one key solution for solving it problem.

But it has powerful mechanism that do the trick (stackoverflow):

:nnoremap K i<cr><esc> 

Because I use Sublime Text in "Vintage mode" solution for me looking differently. In Preferences -> Key Bindings -> User just add following lines:

{
    "keys": ["K"], "command": "insert", "args": {"characters": "\n"},
    "context":
    [
        { "key": "setting.command_mode", "operand": true },
        { "key": "setting.is_widget", "operand": false }
    ]
}

And when you type K in command mode you will split line under cursor.

No comments:

Post a Comment