Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Commands to append after (and insert before) any text object. http://redd.it/1z93ww

View append.vim
1 2 3 4 5 6 7 8 9 10
nnoremap <silent> <Leader>a :set opfunc=Append<CR>g@
nnoremap <silent> <Leader>i :set opfunc=Insert<CR>g@
 
function! Append(type, ...)
call feedkeys("`]a", 'n')
endfunction
 
function! Insert(type, ...)
call feedkeys("`[i", 'n')
endfunction
Owner

Example:

Route::get('/create', 'GamesController@index');

From beginning of line, typing \ai'_foo leads to:

Route::get('/create_foo', 'GamesController@index');

Following up with \ii)1, leads to:

Route::get(1, '/create_foo', 'GamesController@index');
Owner

Combine with targets.vim to enable commands like these:

Route::get('/create', 'GamesController@index');

From beginning of line, typing \i3in'Foo loads to:

Route::get('/create', 'FooGamesController@index');

This does weird things if you try to append to a multi-line textobject (like ip). You might find it preferable to make it start a new line, like this:

nnoremap <silent> <Leader>a :set opfunc=Append<CR>g@
nnoremap <silent> <Leader>i :set opfunc=Insert<CR>g@
function! Append(type, ...)
    normal! `]
    if a:type == 'char'
        call feedkeys("a", 'n')
    else
        call feedkeys("o", 'n')
    endif
endfunction
function! Insert(type, ...)
    normal! `[
    if a:type == 'char'
        call feedkeys("i", 'n')
    else
        call feedkeys("O", 'n')
    endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.