[lug] Vim Modes Question
Bill Thoen
bthoen at gisnet.com
Mon Sep 26 17:25:05 MDT 2005
THanks. I think what threw me is that you have to type those key mappings
fairly quickly to get them to work. As a test, I had defined:
:nmap ,whee 5j
(nothing fancy; just something to see if I could get it to work) and if you
type ',whee' quickly enough, the cursor drops 5 lines in normal mode. If you
type too slowly, it doesn't work. I thought the problem was with the mode
or something like that, but I wasn't typing fast enough.
- Bill Thoen
On Mon, Sep 26, 2005 at 04:16:50PM -0600, Sean Reifschneider wrote:
> On Fri, Sep 23, 2005 at 08:06:17PM -0600, Bill Thoen wrote:
> >I'm trying to understand key mapping in Vim, but I don't understand what
> >Normal and Visual modes are. For example, if I define a key mapping with
> >cmap, it works fine when I press Esc and then : and then enter it. But I
> >don't know how to invoke key mappings created with nmap or vmap. So what
> >are Normal and Visual modes and how do I get nmap and vmap key mappings to
>
> Do ":help modes" and scroll up a page. It should display information about
> the modes:
>
> There are five sets of mappings
> - For Normal mode: When typing commands.
> - For Visual mode: When typing commands while the Visual area is
> highlighted.
> - For Operator-pending mode: When an operator is pending (after "d", "y",
> "c",
> etc.). Example: ":omap { w" makes "y{" work like "yw" and "d{" like "dw".
> - For Insert mode. These are also used in Replace mode.
> - For Command-line mode: When entering a ":" or "/" command.
>
> As it says, visual mode is when you type 'v' and select a region (visual
> region selection). Normal mode is when you are in the normal command mode.
> You can tell what mode you are in by typing "set showmode", it will display
> the mode you are in in the lower left corner of the display, except normal
> mode which shows nothing.
>
> I believe "cmap" is for setting mappings for the command-line mode, hence
> your having to use ":macro". If you just want to map a key to do
> something, us ":map t xp" (for example). Another way you can set up macros
> is to do "qa", then do the things you want the macro to do, then type "q"
> again to finish recording the macro. To invoke it you run "@a", so you
> could ":map t @a", for example. You can record a macro to any buffer, in
> the above we were using buffer "a".
>
> Sean
> --
> Fire at the celuloud factory. No film at eleven.
> -- _Kentucky_Fried_Movie_
> Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
> tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability
>
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
>
More information about the LUG
mailing list