From 46dccf06e4723ea8dbe3a71e213367647ae549f1 Mon Sep 17 00:00:00 2001 From: Thomas Buckley-Houston Date: Tue, 16 May 2017 13:16:57 +0700 Subject: Use `behave mswin`, improves selection behaviour Also updated README --- README.md | 35 +++++++++++++++++++++++++++++++---- plugin/novim-mode.vim | 44 +++++++++++++++++++++++++++++--------------- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index f08ae7f..5a4740f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,38 @@ -# No-vim mode +# No vim keybindings mode -Try to make vim keybindings work like a 'normal' editor. +_Work In Progress_ -WIP +Some, indeed many, may say this is counter-productive or even sacrilegious. But Vim is a lot more than just a keybinding paradigm; firstly it has one of the richest plugin ecosystems of any editor, but also it is a --if not *the* most-- ubiquitous text editor and has been battle tested for over 25 years. There are more reasons to use it than merely its famous shortcut vocabulary. This plugin is an attempt to expose everything else about Vim without the overhead of learning to use Normal mode The Right Way. + +Vim itself already has support for something similar in its optional [`mswin.vim`](https://github.com/vim/vim/blob/master/runtime/mswin.vim) config file. However it still assumes the relevance of Normal mode and `SHIFT+INSERT` combinations. Whereas this plugin attempts to avoid Normal mode unless absolutely necessary, say for interacting with the NERDTree buffer. ## Installation -Eg; +Use your favourite plugin manager, eg, for vim-plug; `Plug 'tombh/novim-mode'` + +## Usage + +Most keybindings should work as you might expect from, say Atom or Sublime Text; `CTRL+S` to save, etc. However there are some differences; + * `CTRL+Z` does not undo, as that is already a well-established *nix shortcut for backgrounding a program. + * CTRL/HOME/END/PAGEUP/PAGEDOWN keys don't work during selection mode. Though large areas of text can be quickly selected with the mouse. It may end up being easier to simulate selection mode with Vim's default Visual mode. + * There seems to be a bug where only `SHIFT+TAB` and not `TAB` works for indenting during selection mode. Again this may be fixed by simulating selection mode with Visual mode in the future. + +### Keybindings + + * `CTRL+S`: Saves the current file + * `SHIFT+ARROW`: Enter selection mode + * `CTRL+C`: Copy selection + * `CTRL+X`: Cut selection + * `CTRL+V`: Paste current selection + * `CTRL+A`: Select all + * `TAB`: Indent selected text [currently broken] + * `SHIFT+TAB`: Unindent selected text + * `CTRL+F`: Find text. `F3` and `SHIFT+F3` find next/previous + * `CTRL+U/R`: Undo/Redo + * `CTRL+K`: Delete current line + * `CTRL+D`: Duplicate current line + * `ALT+UP/DOWN`: Move current line up/down + * `CTRL+Q`: Exit window/tab/split/quickfix/etc + diff --git a/plugin/novim-mode.vim b/plugin/novim-mode.vim index 000d0cb..86536b1 100644 --- a/plugin/novim-mode.vim +++ b/plugin/novim-mode.vim @@ -15,23 +15,31 @@ augroup start_insertmode autocmd BufEnter * call InsertMode() augroup END +" Mostly changes the way selection works. +" See: http://vimdoc.sourceforge.net/htmldoc/gui.html#:behave +" An extract from the docs about the difference between `behave mswin` +" and `behave xterm`: +" mswin xterm +" 'selectmode' 'mouse,key' '' +" 'mousemodel' 'popup' 'extend' +" 'keymodel' 'startsel,stopsel' '' +" 'selection' 'exclusive' 'inclusive' +behave mswin + " Copy and paste stuff -" TODO: -" * Doesn't work when cursor is on the first col -" * Support SHIFT+ARROW in visual mode -inoremap v -inoremap v -inoremap v -inoremap v -inoremap pi -vnoremap yi -vnoremap di +inoremap p +vnoremap y +vnoremap x + +" CTRL-A for selecting all text +inoremap gggHG +cnoremap gggHG +vnoremap gggHG " Indenting -" The `gv` returns you to the exact same selection, so you can repeat the -" command -vnoremap >gv -vnoremap <gv +" TODO: TAB doesn't work in mswin selection mode, but SHIFT+TAB does?? +vnoremap > +vnoremap < " CTRL+q to exit pane/app inoremap :q @@ -40,13 +48,18 @@ nnoremap :q " Find inoremap / +" Find next inoremap n +" Find previous +inoremap N " Clears highlighting. NB. Overriding ESC makes it very hard to get into " NORMAL mode. -inoremap :noh +inoremap :noh " Undo/redo " Doesn't use Ctrl+Z because that's already a significant *nix shortcut +" Unfortunately Vim can't use uppercase (shifted) key combos, otherwise +" we'd use CTRL+SHIFT+U here. inoremap u inoremap @@ -71,6 +84,7 @@ inoremap ^ au BufNewFile,BufRead *.txt,*.md,*.markdown setlocal linebreak spell " Make arrow keys move through wrapped lines " TODO: +" * Make End key move to end of current wrapped piece of line. " * Scroll window 1 wrapped soft line at a time rather an entire block of wrapped " lines. au BufNewFile,BufRead *.txt,*.md,*.markdown inoremap gk -- cgit v1.2.3-70-g09d2