aboutsummaryrefslogtreecommitdiff
path: root/doc/heresy.txt
blob: e602f9dd466669642f4212f7d3114b98be918cae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
*heresy.txt* Vim keybindings for 'conventional' editor behaviour

                        VIM-HERESY DOCUMENTATION

==============================================================================
CONTENTS                                                 |vim-heresy-contents|

    Introduction ................................... |vim-heresy-introduction|
    Installation ................................... |vim-heresy-installation|
    Usage ................................................. |vim-heresy-usage|
    Keybindings ..................................... |vim-heresy-keybindings|
    Interoperability ........................... |vim-heresy-interoperability|
    Known Issues ................................... |vim-heresy-known-issues|
    References ................................. |vim-heresy-known-references|

==============================================================================
1. Introduction                        *vim-heresy* *vim-heresy-introduction*

vim-heresy makes Vim behave like a 'conventional', non-modal editor. Where key
presses default to inserting text, `CTRL+S` saves the file and so on. In the
same way that 'vim-mode' plugins are available for other editors to enable
Vim-style keybindings, so too is 'vim-heresy' available in Vim to enable
'traditional'-style keybindings.

Vim is one of the most battle-tested, ubiquitous and extensible editors
available. If your muscle memory is already fluent with non-vim keybindings
then you will be able to instantly benefit from all that is valuable about
Vim without the learning curve of Normal Mode.

==============================================================================
2. Installation                                     *vim-heresy-installation*

Use your favourite plugin manager, eg, for vim-plug; >

  Plug 'j-james/vim-heresy'`
<

==============================================================================
3. Usage                                                   *vim-heresy-usage*

Most keybindings should work as you might expect from, say Atom or Sublime
Text; `SHIFT+ARROW` to select and `CTRL+C/V` to copy/paste. But don't expect
Vim to completely bend to your will, it is still useful to familiarise yourself
with some of Vim's basic concepts. For instance you may on occasion find
yourself stuck in a particular Vim mode, like when pasting text without 'Paste
Mode' then inserted text can trigger random mappings. In such case `CTRL+Q`
may not kill Vim and you'll need to find a way of getting to Normal Mode and
typing `:q` then `<RETURN>`. Such is life with Vim, this plugin is highly
unlikely to ever change that. (BTW conventional pasting is on by default,
but to exit an errant 'Paste Mode' use `:set nopaste`.)

If you are new to Vim, then perhaps the only remaining confusion after installing
this plugin will be about where files go when you open new ones. This question
will be answered by Vim's concept of 'buffers'. You may wish to install something
like [vim-buftabline](https://github.com/ap/vim-buftabline) to give a familiar
list of open files along the top of the editor.

==============================================================================
4. Keybindings                                       *vim-heresy-keybindings*

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`[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 `vim-heresy` 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 `vim-heresy`'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+;` or `ALT+c`: Vim command prompt.
  * `ALT+o`: Replaces native `CTRL+O` to give one-off Normal Mode commands.

Pane controls
  * `ALT+ARROW`: Change pane/buffer focus.
  * `CTRL+W`: Closes current pane-like thing. Also closes associated
     quickfix and location panes.

Selecting, copy and paste
  * `SHIFT+ARROW`: Select text
  * `CTRL+C`: Copy selection or copy line if no selection.
  * `CTRL+X`: Cut selection or cut line if no selection.
  * `CTRL+V`: Paste current selection.
  * `CTRL+A`: Select all.
  * `CTRL+D`: Select word under cursor. Use something like vim-multicursors
    [1] for multi cursor support.
  * `CTRL+L`: Select line under cursor, repetition selects more lines.

Indenting
  * `TAB` or `ALT+]`: Indent current line or selected text.
  * `SHIFT+TAB` or `ALT+[`: Unindent current line or selected text.

Finding, replacing
  * `CTRL+F`: Find text. When text is selected that selection is searched
    for.
  * `F3` and `SHIFT+F3`: Find next and previous occurences.
  * `CTRL+H`: Find and replace. `[FIND]` and `[REPLACE]` are prepopulated.

Undoing
  * `CTRL+Z` or `CTRL+U`: Undo.
  * `CTRL+Y`: Redo.

Tab navigation
  * `CTRL+T`: Open a new tab.
  * `CTRL+TAB`: Cycle to the next tab.
  * `CTRL+SHIFT+T`: Cycle to the previous tab.

Plugin updating
  * `CTRL+U`: Update installed plugins

Other text manipulation tricks
  * `CTRL+LEFT/RIGHT`: Move cursor per word (works in selection as well).
  * `CTRL+ALT+d`: Delete current line.
  * `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                             *vim-heresy-interoperability*

When adding a new binding of your own that needs Normal mode, you should use
`<C-O>` before the targeted command, for example; >

  " Ensure CtrlP doesn't get overridden by autocomplete in insertmode
  inoremap <C-P> <C-O>:CtrlP<CR>
<

Overriding or disabling shortcuts in this plugin can be done in several
ways. The simplest way is to use: >

  let g:heresy_shortcuts = 0
  inoremap ... custom mapping ...
  call heresy#StartHeresy()
<

Alternatively you can unmap a mapping using commands such as `nunmap`,
`iunmap`, `sunmap`, etc.

Lastly shorcuts are also grouped roughly under the headings described above,
so you may be able to disable one of the
following: >

  let g:heresy_app_shortcuts = 1
  let g:heresy_copypaste_shortcuts = 1
  let g:heresy_undo_shortcuts = 1
  let g:heresy_plugin_shortcuts = 1
  let g:heresy_find_shortcuts = 1
  let g:heresy_line_shortcuts = 1
  let g:heresy_tab_shortcuts = 1
  let g:heresy_pane_shortcuts = 1
  let g:heresy_indentation_shortcuts = 1

  " Small fixes to HOME and PAGEUP behaviour
  let g:heresy_navigation_fixes = 1
  " Allows scrolling through wrapped lines one visual line at a time
  let g:heresy_better_wrap_navigation = 1
<
==============================================================================
6. Known Issues                                     *vim-heresy-known-issues*

  * 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.
  * Mapping `<CTRL+M>` internally means mapping `<RETURN>`. This is a
    throwback to Vim's days as a pure terminal application.
  * `CTRL+BACKSPACE` internally represents `<CTRL+H>`, which can be annoying.
    Again this is a throwback to Vim's days as a pure terminal application.

==============================================================================
7. References                                         *vim-heresy-references*

[1] https://github.com/terryma/vim-multiple-cursors
[2] https://github.com/drmikehenry/vim-fixkey