Skip to content

Instantly share code, notes, and snippets.

@romainl
Created September 23, 2017 13:59
Show Gist options
  • Save romainl/775d7858348b49d66536fdffa73df789 to your computer and use it in GitHub Desktop.
Save romainl/775d7858348b49d66536fdffa73df789 to your computer and use it in GitHub Desktop.
Fun with non-empty lines
" jump to next non-empty line
nnoremap <key> :<C-u>call search('^.\+')<CR>
" jump to previous non-empty line
nnoremap <otherkey> :<C-u>call search('^.\+', 'b')<CR>
" extend visual selection to next non-empty line
xnoremap <key> :<C-u>k`\|call search('^.\+')\|normal! <C-r>=visualmode()<CR>``o<CR>
" extend visual selection to previous non-empty line
xnoremap <otherkey> :<C-u>k`\|call search('^.\+', 'b')\|normal! <C-r>=visualmode()<CR>``o<CR>
" operate to next non-empty line
omap <key> :<C-u>normal! v<key><CR>
"operate to previous non-empty line
omap <otherkey> :<C-u>normal! v<otherkey><CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment