Vim Send Text¶
After pairing with some Sublime users, I noticed a neat feature. Or more accurately, they were rubbing it in my face that their cute editor was better than mine. The feature was SendText. Well, I couldn't let Sublime users have all the fun, and apparently neither could a few other people.
There have been a few other implementations at this feature. These implementations sent the text to a screen or tmux split. Since I don't use either, I couldn't use them a la carte.
This next implementation was good. It's only flaw, IMHO, was it's mappings and naming. The naming "ISlime2" is impossible for me to type on the first try. The mappings overlapped my existing mappings. ISlime2 did all the hard work AppleScript work and provides the Vim function to pass into the AppleScript.
" Send current line nnoremap <silent> <Leader>i<CR> :SendTextCurrentLine<CR> " Send in/around text object - operation pending nnoremap <silent> <Leader>i :set opfunc=sendtext#iTermSendOperator<CR>g@ " Send visual selection vnoremap <silent> <Leader>i :<C-u>call sendtext#iTermSendOperator(visualmode(), 1)<CR> " Move to next line then send it nnoremap <silent> <Leader>ij :SendTextNextLine<CR> " Move to previous line then send it nnoremap <silent> <Leader>ik :SendTextPreviousLine<CR>
Vim Operator Pending¶
One of the main reasons to use Vim is Operator pending. It's at the heart of
vim-sendtext provides an operator
pending function so we can logically do
The identical function works in visual mode to help build confidence in our text
To read more about operator pending functions and how to create them try:
Hope vim-sendtext can remove some feature envy from Sublime. Happy console hacking!