Sunday, 15 June 2014

VIM: Determine if function called from visual-block mode -


Within a function, how can it be determined that the function is called from visible-block mode in the call to function Both are included:

  • General-mode mapping
  • Command line mode

For precise function, fortunately this is similar By way of normal / command mode or visual-mode treats with a single line selected, obviously more than one line - from a: firstline / la The stline - function was not called by normal mode.

The problem now is that I have to know whether I am inside View-Block mode, one line or not.

I have not used any of the following:

  function! [1: 2]] [1: 2]] Echo Visualmoda () Echo mode () Endfen vnoremap TT: Call T () & lt; CR & gt; Nnoremap TT: Call T () & lt; CR & gt;  

Output from view-line mode (notice the crazy maximum-integer output):

  [3, 4] [[3, 1], [ 4, 2147483647]] V n  

I need different types of replies "can not be done" or "step by step" do not make any ambiguity - do this - After this, finish it ... I'm tired of jumping through vague Goldberg-esque deficiencies, just the usual tasks provided by any underlying functionality Not to do the right, and honestly my vim -fu is still young.

Just apply your function like this:

  vnoremap tt : Call T (VisualMode ()) & lt; CR & gt; Nnoremap TT: Call T ('') & lt; CR & gt;  

With an empty argument, the function was implemented with normal mode. Otherwise, the eligible character mode represents (i.e. v vs. V vs ^ v ).


No comments:

Post a Comment