Home Explore Blog CI



neovim

2nd chunk of `runtime/doc/usr_42.txt`
4841c3fcb5cbdfc1bacb0bf73f6ee7dc5fe468e8703e94400000000100000fa2
 to make it appear on
the far right.
   The second number (340) determines the location of the item within the
pull-down menu.  Lower numbers go on top, higher number on the bottom.  These
are the priorities in the File menu:
>
			+-----------------+
	    10.310	|Open...	  |
	    10.320	|Split-Open...	  |
	    10.325	|New		  |
	    10.330	|Close		  |
	    10.335	|---------------- |
	    10.340	|Save		  |
	    10.350	|Save As...	  |
	    10.400	|---------------- |
	    10.410	|Split Diff with  |
	    10.420	|Split Patched By |
	    10.500	|---------------- |
	    10.510	|Print		  |
	    10.600	|---------------- |
	    10.610	|Save-Exit	  |
	    10.620	|Exit		  |
			+-----------------+
<
Notice that there is room in between the numbers.  This is where you can
insert your own items, if you really want to (it's often better to leave the
standard menus alone and add a new menu for your own items).
   When you create a submenu, you can add another ".number" to the priority.
Thus each name in {menu-item} has its priority number.


SPECIAL CHARACTERS

The {menu-item} in this example is "&File.&Save<Tab>:w".  This brings up an
important point: {menu-item} must be one word.  If you want to put a dot,
space or tabs in the name, you either use the <> notation (<Space> and <Tab>,
for instance) or use the backslash (\) escape. >

	:menu 10.305 &File.&Do\ It\.\.\. :exit<CR>

In this example, the name of the menu item "Do It..." contains a space and the
command is ":exit<CR>".

The <Tab> character in a menu name is used to separate the part that defines
the menu name from the part that gives a hint to the user.  The part after the
<Tab> is displayed right aligned in the menu.  In the File.Save menu the name
used is "&File.&Save<Tab>:w".  Thus the menu name is "File.Save" and the hint
is ":w".


SEPARATORS

The separator lines, used to group related menu items together, can be defined
by using a name that starts and ends in a '-'.  For example "-sep-".  When
using several separators the names must be different.  Otherwise the names
don't matter.
   The command from a separator will never be executed, but you have to define
one anyway.  A single colon will do.  Example: >

	:amenu 20.510 Edit.-sep3- :

==============================================================================
*42.2*	Menu commands

You can define menu items that exist for only certain modes.  This works just
like the variations on the ":map" command:

	:menu		Normal, Visual and Operator-pending mode
	:nmenu		Normal mode
	:vmenu		Visual mode
	:omenu		Operator-pending mode
	:menu!		Insert and Command-line mode
	:imenu		Insert mode
	:cmenu		Command-line mode
	:tlmenu		Terminal mode
	:amenu		All modes (except for Terminal mode)

To avoid that the commands of a menu item are being mapped, use the command
":noremenu", ":nnoremenu", ":anoremenu", etc.


USING :AMENU

The ":amenu" command is a bit different.  It assumes that the {keys} you
give are to be executed in Normal mode.  When Vim is in Visual or Insert mode
when the menu is used, Vim first has to go back to Normal mode.  ":amenu"
inserts a CTRL-C or CTRL-O for you.  For example, if you use this command:
>
	:amenu  90.100 Mine.Find\ Word  *

Then the resulting menu commands will be:

	Normal mode:		`*`
	Visual mode:		CTRL-C `*`
	Operator-pending mode:	CTRL-C `*`
	Insert mode:		CTRL-O `*`
	Command-line mode:	CTRL-C `*`

When in Command-line mode the CTRL-C will abandon the command typed so far.
In Visual and Operator-pending mode CTRL-C will stop the mode.  The CTRL-O in
Insert mode will execute the command and then return to Insert mode.
   CTRL-O only works for one command.  If you need to use two or more
commands, put them in a function and call that function.  Example: >

	:amenu  Mine.Next\ File  :call <SID>NextFile()<CR>
	:function <SID>NextFile()
	:  next
	:  1/^Code
	:endfunction

This menu entry goes to the next file in the argument list with ":next".  Then
it searches for the line that starts with "Code".
   The <SID>

Title: Menu Item Details and Commands
Summary
This section details the use of special characters, separators, and various menu commands in Vim. It explains how to include spaces and tabs in menu item names using escape characters and the '<Tab>' character for hints. It also covers different menu commands for specific modes (Normal, Visual, Insert, etc.) and the use of ':amenu' for commands that need to switch to Normal mode before execution. Additionally, it discusses the use of separators to group menu items and provides examples of using functions with menu entries.