diff options
-rw-r--r-- | README.md | 33 | ||||
-rw-r--r-- | autoload/novim_mode.vim | 9 | ||||
-rw-r--r-- | doc/novim_mode.txt | 28 | ||||
-rw-r--r-- | plugin/novim_mode.vim | 6 |
4 files changed, 50 insertions, 26 deletions
@@ -1,6 +1,6 @@ # No Vim Keybindings Mode [![Build Status](https://travis-ci.org/tombh/novim-mode.svg?branch=master)](https://travis-ci.org/tombh/novim-mode) -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 that's been battle tested for over 25 years. There are more reasons to use it than merely its famous shortcut vocabulary. +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 that's 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 cultivating Normal Mode fluency. This is not a rebellion, it is merely a manifestation of the distinction between Vim the editor and Vim the keybinding paradigm. Please do not dismiss Normal Mode just because this plugin exists, give `vimtutor` a try, modal editing is popular for a reason. @@ -22,18 +22,26 @@ If you are new to Vim, then perhaps the only remaining confusion after installin ### Keybindings -Many terminals default to intercepting `CTRL+S` to suspend output, if so you will need to disable this behaviour. Most terminals will also bind the `CTRL+Q` to undo the suspend, useful, but you will also need to unmap that, or change the mapping in this plugin for quitting Vim. +#### Vim in the terminal +Both Vim and Neovim can be used both as GUI apps and in the terminal. However, original Vim in the terminal has problems with many key combinations - essentially most combinations that are not a plain `CTRL+KEY`. To get around this you can use the [vim-fixkey](https://github.com/drmikehenry/vim-fixkey) plugin. It does have some caveats, which you can read about in its docs, but basically it just makes recording macros a little bit more tricky because of the timing between `Esc` combinations. `vim-fixkey` also doesn't enable `ALT+non-alphanumeric` combinations, but `novim-mode` usually has alphanumeric siblings which you can still use. However, if you are not particularly tied to Vim, you can use Neovim in the terminal which has much better support for key combinations and will work without the need for `vim-fixkey`. Note that the GUI versions of both Vim and Neovim also don't have these key combination problems. -`CTRL`-based shortcuts are paired with uppercase letters here because Vim -does not recognise the difference between cases when using `CTRL` combinations and -documenting in uppercase implies something of this distinction. +Most terminal emulators (ie. `xterm`, `rxvt`, `PuTTY`, etc) default to intercepting `CTRL+S` to suspend output (`CTRL+Q` unsuspends if you're wondering), if so you will need to disable this behaviour to use `novim-mode`'s shortcuts for saving and quitting. Most often you simply need to add the following to your `~/.bashrc`, `~/.zshrc` or similar: + +```sh +stty -ixon +stty stop undef +``` + +However some GUI terminals also have their own settings for suspension. For instance Konsole, which can be unset by going to `Settings -> Configure Profile -> Choose current profile -> Edit Profile -> Advanced Tab` and disabling `Enable flow control using Ctrl+S and Ctrl+Q` + +One further common problem is that `tmux` can change key combination behaviour, most notably for `SHIFT+ARROW` combinations, to overcome this add `set-window-option -g xterm-keys` to your `~/.tmux.conf` config. #### General editor shortcuts * `CTRL+N`: Open a new file. * `CTRL+O`: Open an existing file. * `CTRL+S`: Saves the current file. * `CTRL+G`: Goto line. - * `ALT+;`: Vim command prompt. + * `ALT+;` or `ALT+c`: Vim's command prompt. * `ALT+o`: Replaces native `CTRL+O` to give one-off Normal Mode commands. #### Pane controls @@ -50,7 +58,7 @@ documenting in uppercase implies something of this distinction. * `CTRL+L`: Select line under cursor, repetition selects more lines. #### Indenting - * `TAB` or `ALT+]`: Indent current line or selected text. _[`TAB` currently broken]_ + * `TAB` or `ALT+]`: Indent current line or selected text. _`TAB` currently broken for Neovim_ * `SHIFT+TAB` or `ALT+[`: Unindent current line or selected text. #### Finding, replacing @@ -64,10 +72,14 @@ documenting in uppercase implies something of this distinction. #### Other text manipulation tricks * `CTRL+LEFT/RIGHT`: Move cursor per word (works in selection as well). - * `CTRL+ALT+k`: Delete current line. - * `CTRL+ALT+d`: Duplicate current line. + * `CTRL+ALT+k`: Delete current line. _Currently broken in terminal Vim_ + * `CTRL+ALT+d`: Duplicate current line. _Currently broken in terminal Vim_ * `CTRL+UP/DOWN`: Move current line or selected text up/down. +_Note that `CTRL`-based shortcuts are paired with uppercase letters in these docs because +Vim does not recognise the difference between cases when using `CTRL` combinations and +documenting in uppercase implies something of this distinction._ + ### Interoperability When adding a new binding of your own that needs Normal mode, you should use `<C-O>` before the targeted command, for example; ```vim @@ -82,8 +94,7 @@ inoremap ... custom mapping ... call novim_mode#StartNoVimMode() ``` -Shortcuts are also grouped roughly under the headings described above, so you may be able to disable -one of the following: +Shortcuts are also grouped roughly under the headings described above, so you may be able to disable one of the following: ```vim let g:novim_mode_use_general_app_shortcuts = 1 let g:novim_mode_use_pane_controls = 1 diff --git a/autoload/novim_mode.vim b/autoload/novim_mode.vim index 549210e..445b2c3 100644 --- a/autoload/novim_mode.vim +++ b/autoload/novim_mode.vim @@ -92,7 +92,9 @@ function! g:SetNoVimModeShortcuts() " ALT+; for command prompt inoremap <M-;> <C-O>: + inoremap <M-c> <C-O>: nnoremap <M-;> : + nnoremap <M-c> : " <ALT+o> replaces native <C-O> for one-time normal mode commands. inoremap <M-o> <C-O> @@ -164,7 +166,7 @@ function! g:SetNoVimModeShortcuts() " Indenting if g:novim_mode_use_indenting == 1 - " TODO: TAB doesn't work in mswin selection mode, but SHIFT+TAB does?? + " TODO: In Neovim TAB doesn't work in mswin selection mode, but SHIFT+TAB does?? snoremap <Tab> <C-O>>gv inoremap <M-]> <C-T> snoremap <M-]> <C-O>>gv @@ -185,9 +187,6 @@ function! g:SetNoVimModeShortcuts() inoremap <S-F3> <C-O>N " Find and replace inoremap <C-H> <C-O>:%s/[FIND]/[REPLACE]/g - " Clears highlighting. - " NB. Overriding ESC makes it harder to get into NORMAL mode. - inoremap <silent> <Esc> <C-O>:noh<CR> endif " Undo/redo @@ -211,10 +210,12 @@ function! g:SetNoVimModeShortcuts() " text. if g:novim_mode_use_text_tricks == 1 " CTRL+ALTt+k deletes the current line under the cursor + " TODO: Doesn't work in terminal vim, even with vim-fixkey inoremap <silent> <C-M-K> <C-O>"_dd " CTRL+ALT+d duplicates current line. " NB. Uses the named 'd' register. + " TODO: Doesn't work in terminal vim, even with vim-fixkey inoremap <silent> <C-M-D> <C-O>"dyy<C-O>"dp " CTRL+DOWN/UP moves the current/selected line(s) up and down diff --git a/doc/novim_mode.txt b/doc/novim_mode.txt index f249308..ee277cd 100644 --- a/doc/novim_mode.txt +++ b/doc/novim_mode.txt @@ -58,21 +58,26 @@ list of open files along the top of the editor. ============================================================================== 4. Keybindings *novim-mode-keybindings* -Many terminals default to intercepting `CTRL+S` to suspend output, if so you -will need to disable this behaviour. Most terminals will also bind `CTRL+Q` -to undo the suspend, useful, but you will also need to unmap that, or change -the mapping in this plugin for quitting Vim. +Vim in the terminal -`CTRL`-based shortcuts are paired with uppercase letters here because Vim -does not recognise the difference between cases when using `CTRL` combinations -and documenting in uppercase implies something of this distinction. +Both Vim and Neovim can be used both as GUI apps and in the terminal. However, original Vim in the terminal has problems with many key combinations - essentially most combinations that are not a plain `CTRL+KEY`. To get around this you can use the `vim-fixkey`[2] plugin. It does have some caveats, which you can read about in its docs, but basically it just makes recording macros a little bit more tricky because of the timing between `Esc` combinations. `vim-fixkey` also doesn't enable `ALT+non-alphanumeric` combinations, but `novim-mode` usually has alphanumeric siblings which you can still use. However, if you are not particularly tied to Vim, you can use Neovim in the terminal which has much better support for key combinations and will work without the need for `vim-fixkey`. Note that the GUI versions of both Vim and Neovim also don't have these key combination problems. + +Most terminal emulators (ie. `xterm`, `rxvt`, `PuTTY`, etc) default to intercepting `CTRL+S` to suspend output (`CTRL+Q` unsuspends if you're wondering), if so you will need to disable this behaviour to use `novim-mode`'s shortcuts for saving and quitting. Most often you simply need to add the following to your `~/.bashrc`, `~/.zshrc` or similar: > + +stty -ixon +stty stop undef +< + +However some GUI terminals also have their own settings for suspension. For instance Konsole, which can be unset by going to `Settings -> Configure Profile -> Choose current profile -> Edit Profile -> Advanced Tab` and disabling `Enable flow control using Ctrl+S and Ctrl+Q` + +One further common problem is that `tmux` can change key combination behaviour, most notably for `SHIFT+ARROW` combinations, to overcome this add `set-window-option -g xterm-keys` to your `~/.tmux.conf` config. General editor shortcuts * `CTRL+N`: Open a new file. * `CTRL+O`: Open an existing file. * `CTRL+S`: Saves the current file. * `CTRL+G`: Goto line. - * `ALT+;`: Vim command prompt. + * `ALT+;` or `ALT+c`: Vim command prompt. * `ALT+o`: Replaces native `CTRL+O` to give one-off Normal Mode commands. Pane controls @@ -92,7 +97,6 @@ Selecting, copy and paste Indenting * `TAB` or `ALT+]`: Indent current line or selected text. - _[`TAB` currently broken]_ * `SHIFT+TAB` or `ALT+[`: Unindent current line or selected text. Finding, replacing @@ -111,6 +115,10 @@ Other text manipulation tricks * `CTRL+ALT+k`: Duplicate current line. * `CTRL+UP/DOWN`: Move current line or selected text up/down. + +`CTRL`-based shortcuts are paired with uppercase letters here because Vim +does not recognise the difference between cases when using `CTRL` combinations +and documenting in uppercase implies something of this distinction. ============================================================================== 5. Interoperability *novim-mode-interoperability* @@ -164,4 +172,4 @@ following: > 7. References *novim-mode-references* [1] https://github.com/terryma/vim-multiple-cursors - +[2] https://github.com/drmikehenry/vim-fixkey diff --git a/plugin/novim_mode.vim b/plugin/novim_mode.vim index d5601b1..97d61c6 100644 --- a/plugin/novim_mode.vim +++ b/plugin/novim_mode.vim @@ -38,7 +38,11 @@ endfunction call s:init_settings(s:settings) " Plugin entry point -call novim_mode#StartNoVimMode() +if has('timers') + call g:novim_mode#StartNoVimMode() +else + echo 'Novim-mode will not work this version of Vim (no `timer` support).' +endif let &cpo = s:save_cpo unlet s:save_cpo |