From e00abb7772d53f118ca8662a0fcca03e2423c25d Mon Sep 17 00:00:00 2001 From: Thomas Buckley-Houston Date: Tue, 25 Jul 2017 16:48:43 +0700 Subject: Better non-wrapped HOME/END. Use system clipboard. --- autoload/novim_mode.vim | 78 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 27 deletions(-) (limited to 'autoload') diff --git a/autoload/novim_mode.vim b/autoload/novim_mode.vim index 90aecc5..f992b3f 100644 --- a/autoload/novim_mode.vim +++ b/autoload/novim_mode.vim @@ -109,18 +109,11 @@ function! g:SetNoVimModeShortcuts() " General fixes to editor behaviour if g:novim_mode_use_editor_fixes == 1 - " All thee `g`s here make these also work for wrapped lines. - " Fix HOME to go back to the first non-whitespace character of the line. - inoremap g^ - " Native End would work anyway but it needs the `g` for wrapped lines - inoremap g$ - - " For selection behaviour - inoremap g^ - snoremap g^ - inoremap g$ - snoremap g$ + inoremap ^ + " The same but for selection behaviour + inoremap ^ + snoremap ^ " Tweaks PageUp behaviour to get cursor to first line on top page inoremap :call novim_mode#PageUp() @@ -155,14 +148,14 @@ function! g:SetNoVimModeShortcuts() " One of those curious features of Vim: without `onemore` when pasting " at the end of a line, pasted text gets put *before* the cursor. set virtualedit=onemore - " NB. All these use the named 'p' register. - inoremap "pP - snoremap "pP - cnoremap "p - snoremap "pygv - inoremap "pY - snoremap "pxi - inoremap "pdd + " NB. All these use the system clipboard. + inoremap "+P + snoremap "+P + cnoremap "+ + snoremap "+ygv + inoremap "+Y + snoremap "+xi + inoremap "+dd " Select word under cursor inoremap viw " Select current line @@ -239,26 +232,57 @@ endfunction " By default Vim treats wrapped text as a single line even though it may " appear as many lines on screen. So here we try to make wrapped text behave -" more conventionally. +" more conventionally. Please add any new types you might come across. function! s:SetWrappedTextNavigation() + autocmd BufNewFile,BufRead *.{ + \md, + \mdown, + \markdown, + \txt, + \textile, + \rdoc, + \org, + \creole, + \mediawiki + \} setlocal filetype=txt + autocmd FileType \ + \rst, + \asciidoc, + \pod, + \txt + \ call s:WrappedTextBehaviour() +endfunction + +function! s:WrappedTextBehaviour() " Allow text to wrap in text files - au BufNewFile,BufRead *.txt,*.md,*.markdown setlocal linebreak spell wrap + setlocal linebreak wrap " Make arrow keys move through wrapped lines " TODO: - " * Scroll window 1 wrapped soft line at a time rather than entire block of wrapped - " lines. - au BufNewFile,BufRead *.txt,*.md,*.markdown inoremap gk - au BufNewFile,BufRead *.txt,*.md,*.markdown inoremap gj + " * Scroll window 1 wrapped soft line at a time rather than entire block + " of wrapped lines -- I'm as good as certain this will need a patch to + " (n)vim's internals. + inoremap gk + inoremap gj + " For selection behaviour + snoremap gk + snoremap gj + " HOME/END for *visible* lines, not literal lines + inoremap g^ + inoremap g$ " For selection behaviour - au BufNewFile,BufRead *.txt,*.md,*.markdown snoremap gk - au BufNewFile,BufRead *.txt,*.md,*.markdown snoremap gj + inoremap g^ + snoremap g^ + inoremap g$ + snoremap g$ endfunction " Try to intuitively and intelligently close things like buffers, splits, " panes, quicklist, etc, basically anything that looks like a pane. function! novim_mode#ClosePane() if s:IsEditableBuffer() == 1 + " TODO: These aren't actually formally associated with a buffer, although + " conceptually they often are (eg; linting errors, file search). " Close any location lists on screen. exe "lclose" " Close any quickfix lists on screen. -- cgit v1.2.3-70-g09d2