changing key bindings in visual-block state only

Frank Fischer frank-fischer at shadow-soft.de
Wed Feb 13 10:15:24 CET 2013


On 2013-02-13, Patrick Brinich-Langlois <pbrinichlanglois at gmail.com> wrote:
> Is it possible to change settings only in visual-block state but not
> in visual state? I want to remap a key binding only in visual-block
> state, and there seems not to be a hook for this specific purpose,
> though there are hooks for entering and exiting visual state.

Currently this is not possible, sorry. Maybe we should make each
visual state a full state on its own, but this would be a bigger (at
least not-so-small) change. Currently the type of the visual state is
merely a property of "the" visual state.

In the meantime, you could advise the respective functions that select
the visual states, i.e., `evil-visual-char', `evil-visual-line' and
`evil-visual-block', to change the keybindings in
`evil-visual-state-map' (or `evil-visual-state-local-map')
appropriately (untested):

    (defadvice evil-visual-char (before evil activate)
	  (define-key evil-visual-state-local-map <your-key> <char-function>))

    (defadvice evil-visual-line (before evil activate)
	  (define-key evil-visual-state-local-map <your-key> <line-function>))

    (defadvice evil-visual-block (before evil activate)
	  (define-key evil-visual-state-local-map <your-key> <block-function>))

>
> Also, what's the difference between normal state and motion state?
> I've tried various commands in both modes and they seem to do the
> same things.

Normal state 'inherits' motion state, everything available in motion
state is also available in normal state, but not the other way around.
In motion state only motion commands are available but no editing
commands. For example, you cannot delete a character 'x' or switch to
insert state 'i' when in motion state. However, in normal editing
buffers you will never be in motion state. But some buffers cannot be
edited (or should not), e.g. Info-state buffers (M-x info). These
buffers come up in motion state, providing only motion commands like
h,j,k,l or window commands C-w ..., but no editing commands.

Best regards,
Frank




More information about the implementations-list mailing list