LyXLyX for vim user: normal_mode, insert_mode

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
nilo888
Posts: 1
Joined: Sun Dec 04, 2011 7:20 pm

LyX for vim user: normal_mode, insert_mode

Post by nilo888 »

Hallo to you all,
I want to use lyx with vim's mode. I have found a way: using a strange rebind of keys.

I hope that some other vim user could help me to improve this and give me some advices.

The trick is to use the LFUN(lyx function) meta-prefix. After you have given this lfun, for example i, lyx understand Meta-i(not only i) and if Meta-i give a command and then a meta-prefix lfun, an other key (e) will be interpreted as Meta-e.
Now if we do this for a lot of (maybe all) keys we will be in a mode in which all keys are interpreted as meta-(key). Remapping all meta-(keys) we map the normal mode.
Now with C-c(for me, but if you don't like it you can use C-j or the key you prefer) we send a meta-prefix command and enter in the NORMAL_MODE, and with i (interpreted as Meta-i) we enter in the INSERT_MODE.
I have compiled a short(long!!) map key put this file name as my.bind in ~/.lyx/bind/ and in menu/tools/preferences/... I have set it as a configuration file for shot-keys.

this is my my.bind (obviously is incomplete ad to improve but is a start)

the problem now in the VISUAL_MODE I have do this mode with the shift pressed!

Code: Select all


# ~/.lyx/bind/cua.bind
#
# Happy tuning!

# Free bindings:

#\bind "C-h"
#\bind "C-j"

#\unbind "C-period" "specialchar-insert end-of-sentence"
\unbind "C-period"

\bind "M-S-A" "meta-prefix"
\bind "M-S-B" "meta-prefix"
\bind "M-S-C" "meta-prefix"
\bind "M-S-D" "meta-prefix"
\bind "M-S-E" "meta-prefix"
\bind "M-S-F" "meta-prefix"
\bind "M-S-G" "meta-prefix"
\bind "M-S-H" "meta-prefix"
\bind "M-S-I" "meta-prefix"
\bind "M-S-J" "meta-prefix"
\bind "M-S-K" "meta-prefix"
\bind "M-S-L" "meta-prefix"
\bind "M-S-M" "meta-prefix"
\bind "M-S-N" "meta-prefix"
\bind "M-S-O" "meta-prefix"
\bind "M-S-P" "meta-prefix"
\bind "M-S-Q" "meta-prefix"
\bind "M-S-R" "meta-prefix"
\bind "M-S-S" "meta-prefix"
\bind "M-S-T" "meta-prefix"
\bind "M-S-U" "meta-prefix"
\bind "M-S-V" "meta-prefix"
\bind "M-S-W" "meta-prefix"
\bind "M-S-X" "meta-prefix"
\bind "M-S-Y" "meta-prefix"
\bind "M-S-Z" "meta-prefix"

#\bind "M-a" "meta-prefix"		# other lyx cua bindings
\bind "M-b" "meta-prefix"
#\bind "M-c" "meta-prefix"		# mio comandi
\bind "M-d" "meta-prefix"
#\bind "M-e" "meta-prefix"
\bind "M-f" "meta-prefix"
#\bind "M-g" "meta-prefix"		#vim N_g
#\bind "M-h" "meta-prefix"
\bind "M-i" "meta-prefix"
#\bind "M-j" "meta-prefix"
#\bind "M-k" "meta-prefix"
#\bind "M-l" "meta-prefix"
#\bind "M-m" "meta-prefix"		#funz matematiche
\bind "M-n" "meta-prefix"
\bind "M-o" "meta-prefix"
#\bind "M-p" "meta-prefix"		#tipo di paragrafo
#\bind "M-q" "meta-prefix"		#bookmarks
\bind "M-r" "meta-prefix"
\bind "M-s" "meta-prefix"
\bind "M-t" "meta-prefix"
#\bind "M-u" "meta-prefix"
\bind "M-v" "meta-prefix"
\bind "M-w" "meta-prefix"
#\bind "M-x" "meta-prefix"
\bind "M-y" "meta-prefix"
\bind "M-z" "meta-prefix"

\bind "M-semicolon"		"meta-prefix" # ;
\bind "M-comma"			"meta-prefix" # ,
\bind "M-S-less"		"meta-prefix" # <
\bind "M-S-greater"		"meta-prefix" # >
#\bind "M-apostrophe"		"meta-prefix" # '
\bind "M-S-quotedbl"		"meta-prefix" # "

 # goto NORMAL MODE
\bind "C-c" "meta-prefix" 	#for Dvorak
#\bind "C-j" "meta-prefix"	#if turn on this,eliminate other C-j remap!!
#\bind "C-c" "command-sequence cancel;meta-prefix;" 	
 # goto INSERT MODE
\bind "M-i" "cancel"

 # move,select
\bind "M-l" "command-sequence char-right;meta-prefix"
\bind "M-j" "command-sequence down;meta-prefix"
\bind "M-k" "command-sequence up;meta-prefix"
\bind "M-h" "command-sequence char-left;meta-prefix"

\bind "M-S-l" "command-sequence char-right-select;meta-prefix"
\bind "M-S-j" "command-sequence down-select;meta-prefix"
\bind "M-S-k" "command-sequence up-select;meta-prefix"
\bind "M-S-h" "command-sequence char-left-select;meta-prefix"

 # move,select by word
#\bind "M-b"			"command-sequence word-backward;meta-prefix;"
#\bind "M-w"			"command-sequence word-forward;meta-prefix;"
#\bind "M-S-B"			"command-sequence word-backward-select;meta-prefix;"
#\bind "M-S-W"			"command-sequence word-forward-select;meta-prefix;"
\bind "M-b"			"command-sequence word-left;meta-prefix;"
\bind "M-w"			"command-sequence word-right;meta-prefix;"
\bind "M-S-B"			"command-sequence word-left-select;meta-prefix;"
\bind "M-S-W"			"command-sequence word-right-select;meta-prefix;"
\bind "M-v"			"command-sequence word-select;meta-prefix;"
 # undo,redo and delete
\bind "M-u"			"command-sequence undo;meta-prefix"
\bind "C-M-r"			"command-sequence redo;meta-prefix"
\bind "C-h" 			"char-delete-backward"
\bind "C-w" 			"word-delete-backward"
\bind "M-S-x"			"command-sequence char-delete-backward;meta-prefix;"
\bind "M-x"			"command-sequence char-delete-forward;meta-prefix;"
 #begin,end
\bind "M-g g"			"command-sequence buffer-begin;meta-prefix;"
\bind "M-S-g"			"command-sequence buffer-end;meta-prefix;"
 #cut,copy,paste
\bind "M-d"			"command-sequence cut;meta-prefix;"
\bind "M-S-d"			"command-sequence cut;meta-prefix;"
\bind "M-y"			"command-sequence copy;meta-prefix;"
\bind "M-S-y"			"command-sequence copy;meta-prefix;"
#\bind "M-p"			"command-sequence paste;meta-prefix;"
\bind "M-S-p"			"command-sequence paste;meta-prefix;"
 #bookmark save
\bind "M-q a"			"command-sequence bookmark-save 1;meta-prefix;"
\bind "M-q e"			"command-sequence bookmark-save 2;meta-prefix;"
\bind "M-q i"			"command-sequence bookmark-save 3;meta-prefix;"
\bind "M-q o"			"command-sequence bookmark-save 4;meta-prefix;"
\bind "M-q u"			"command-sequence bookmark-save 5;meta-prefix;"
\bind "M-q apostrophe"		"command-sequence bookmark-clear;meta-prefix;"
 #bookmark goto
\bind "M-apostrophe a"		"command-sequence bookmark-goto 1;meta-prefix;"
\bind "M-apostrophe e"		"command-sequence bookmark-goto 2;meta-prefix;"
\bind "M-apostrophe i"		"command-sequence bookmark-goto 3;meta-prefix;"
\bind "M-apostrophe o"		"command-sequence bookmark-goto 4;meta-prefix;"
\bind "M-apostrophe u"		"command-sequence bookmark-goto 5;meta-prefix;"


\bind "C-apostrophe" 		"completion-cancel"
\bind "C-dollar"		"cut"
\bind "C-ampersand" 		"copy"
\bind "C-braceleft"		"paste"
\bind "C-M-dollar"		"cut"
\bind "C-M-ampersand" 		"copy"
\bind "C-M-braceleft"		"paste"
\bind "M-S-colon" "command-sequence command-execute;meta-prefix"


###

Format 1

\bind "C-n"			"buffer-new"
#\bind "C-S-N"			"buffer-new-template"
#\bind "C-o"			"file-open"
#\bind "C-w"			"buffer-close"
\bind "C-s"			"buffer-write"
#\bind "C-S-S"			"buffer-write-as"
#\bind "C-p"			"dialog-show print"
\bind "C-r"			"buffer-view"
#\bind "C-d"			"buffer-view dvi"	# 'd' for dvi
#\bind "C-t"			"buffer-view ps"
#\bind "C-M-r"			"master-buffer-view"
#\bind "C-M-t"			"master-buffer-view ps"
#\bind "C-M-d"			"master-buffer-view dvi"
#\bind "C-S-R"			"buffer-update"
#\bind "C-S-D"			"buffer-update dvi"	# 'd' for dvi
#\bind "C-S-T"			"buffer-update ps"
#\bind "C-M-S-t"			"master-buffer-update ps"
#\bind "C-M-S-d"			"master-buffer-update dvi"
#\bind "C-q"			"lyx-quit"
#\bind "C-Next"			"buffer-next"
\bind "C-Tab"			"buffer-next"
#\bind "C-Prior"			"buffer-previous"
\bind "C-S-BackTab"		"buffer-previous"
#
#\bind "C-M-b"			"font-boldsymbol"
\bind "C-b"			"font-bold"
\bind "C-e"			"font-emph"
 # used below for line-delete-forward
 #\bind "C-k"			"font-noun"		# 'k' for capitals
\bind "C-u"			"font-underline"
\bind "C-S-P"			"font-typewriter" # 'P' for Program
\bind "C-S-O"			"font-strikeout"

\bind "C-m"			"math-mode"
\bind "C-S-M"			"math-display"
#\bind "C-M-n"			"command-sequence math-display; math-number-toggle;"
\bind "M-S-n" 			"command-sequence math-display; math-number-toggle;"

\bind "C-f"			"dialog-show findreplace"
\bind "C-S-f"			"dialog-show findreplaceadv"
#\bind "C-i"			"inset-toggle"		# 'i' for Inset

#\bind "C-c"			"copy"
#\bind "C-x"			"cut"
#\bind "C-v"			"paste"
#\bind "C-S-v"			"clipboard-paste"
#\bind "C-M-v"			"primary-selection-paste"

#\bind "C-a"			"command-sequence buffer-begin ; buffer-end-select"   # select all
#\bind "C-M-a"			"inset-select-all"

#\bind "C-S-E"			"changes-track"  # it's what MS Word uses
#\bind "~S-M-quotedbl"		"quote-insert single"
#\bind "~S-C-quotedbl"		"self-insert \""
#\bind "C-minus"	"specialchar-insert hyphenation"
#\bind "C-S-underscore"		"math-macro-fold"
#\bind "C-M-minus"		"specialchar-insert nobreakdash"
#\bind "M-S-Right"		"depth-increment"
#\bind "M-S-Left"		"depth-decrement"
#\bind "C-S-L"			"specialchar-insert ligature-break"
#\bind "C-~S-slash"		"specialchar-insert slash"
\bind "C-l"			"ert-insert"		# 'l' for LaTeX
\bind "C-S-I"			"info-insert"

#bind "F1"			"help"			# Not yet implemented!
#bind "C-F1"			"help-context"		# Not yet implemented!
#\bind "F2"			"buffer-write"
#\bind "F3"			"word-find"
#\bind "C-F4"			"buffer-close"
#\bind "M-F4"			"lyx-quit"
#\bind "F5"			"screen-recenter"
#\bind "C-M-Up"			"scroll line up"
#\bind "C-M-Down"		"scroll line down"
#\bind "C-M-Prior"		"scroll page up"
#\bind "C-M-Next"		"scroll page down"
#\bind "C-F6"			"buffer-next"
#\bind "C-S-F6"			"buffer-previous"
#\bind "F7"			"dialog-show spellchecker"
#\bind "S-F7"			"thesaurus-entry"

#\bind "M-x"			"command-execute"
\bind "C-M-o"			"dialog-show toc"

\bind "F11"			"ui-toggle fullscreen"

\bind "M-equal"	"buffer-zoom-in"
\bind "M-plus"		"buffer-zoom-in"
\bind "M-minus"	"buffer-zoom-out"

#
# Motion group
#

#\bind "M-Up"			"paragraph-move-up"
#\bind "M-Down"			"paragraph-move-down"
\bind "C-Right"			"word-right"
\bind "C-Left"			"word-left"
\bind "C-Up"			"paragraph-up"
\bind "C-Down"			"paragraph-down"
\bind "C-Home"			"buffer-begin"
\bind "C-End"			"buffer-end"
#\bind "M-C-Home"		"inset-begin"
#\bind "M-C-End"			"inset-end"

#\bind "C-~S-greater"		"label-goto"
#\bind "C-~S-less" 		"bookmark-goto 0"


#
# Motion + select group
#

\bind "S-Right"			"char-right-select"
\bind "S-Left"			"char-left-select"
\bind "S-Up"			"up-select"
\bind "S-Down"			"down-select"
\bind "S-C-Right"		"word-right-select"
\bind "S-C-Left"		"word-left-select"
\bind "S-C-Up"			"paragraph-up-select"
\bind "S-C-Down"		"paragraph-down-select"
\bind "S-Home"			"line-begin-select"
\bind "S-End"			"line-end-select"
\bind "S-Prior"			"screen-up-select"
\bind "S-Next"			"screen-down-select"
\bind "S-C-Home"		"buffer-begin-select"
\bind "S-C-End"			"buffer-end-select"
\bind "S-M-C-Home"		"inset-begin-select"
\bind "S-M-C-End"		"inset-end-select"
\bind "C-Insert"		"copy"
\bind "S-Insert"		"paste"
\bind "S-Delete"		"cut"

# Numeric keypad (if Shift+KP_XXX does not switch the NumLock state)
\bind "S-KP_Right"              "char-right-select"
\bind "S-KP_Left"               "char-left-select"
\bind "S-KP_Up"                 "up-select"
\bind "S-KP_Down"               "down-select"
\bind "S-C-KP_Right"            "word-right-select"
\bind "S-C-KP_Left"             "word-left-select"
\bind "S-C-KP_Up"               "paragraph-up-select"
\bind "S-C-KP_Down"             "paragraph-down-select"
\bind "S-KP_Home"               "line-begin-select"
\bind "S-KP_End"                "line-end-select"
\bind "S-KP_Prior"              "screen-up-select"
\bind "S-KP_Next"               "screen-down-select"
\bind "S-C-KP_Home"             "buffer-begin-select"
\bind "S-C-KP_End"              "buffer-end-select"
\bind "S-C-KP_Prior"            "buffer-begin-select"
\bind "S-C-KP_Next"             "buffer-end-select"
\bind "C-KP_Insert"             "copy"
\bind "S-KP_Insert"             "paste"
\bind "S-KP_Delete"             "cut"

#
# bookmarks
#

\bind "C-~S-1"			"bookmark-goto 1"
\bind "C-~S-2"			"bookmark-goto 2"
\bind "C-~S-3"			"bookmark-goto 3"
\bind "C-~S-4"			"bookmark-goto 4"
\bind "C-~S-5"			"bookmark-goto 5"
\bind "C-~S-6"			"bookmark-goto 6"
\bind "C-~S-7"			"bookmark-goto 7"
\bind "C-~S-8"			"bookmark-goto 8"
\bind "C-~S-9"			"bookmark-goto 9"
\bind "C-M-~S-1"		"bookmark-save 1"
\bind "C-M-~S-2"		"bookmark-save 2"
\bind "C-M-~S-3"		"bookmark-save 3"
\bind "C-M-~S-4"		"bookmark-save 4"
\bind "C-M-~S-5"		"bookmark-save 5"
\bind "C-M-~S-6"		"bookmark-save 6"
\bind "C-M-~S-7"		"bookmark-save 7"
\bind "C-M-~S-8"		"bookmark-save 8"
\bind "C-M-~S-9"		"bookmark-save 9"


#
# Edit group
#

\bind "C-Delete"		"word-delete-forward"
\bind "C-BackSpace"		"word-delete-backward"
#\bind "M-Return"		"break-paragraph inverse"
\bind "C-Return"		"newline-insert newline"
\bind "C-S-Return"		"newline-insert linebreak"
\bind "C-k"			"line-delete-forward"
\bind "C-space"			"space-insert protected"
\bind "nobreakspace"		"space-insert protected"
\bind "C-M-space"		"space-insert normal"
\bind "S-C-space"		"space-insert thin"
#\bind "C-period"		"specialchar-insert end-of-sentence"
\bind "M-period"		"specialchar-insert dots"
\bind "Escape"			"cancel"
\bind "F9"			"meta-prefix"

# Include menu and math bindings

\bind_file menus.bind
\bind_file math.bind
\bind_file latinkeys.bind
\bind_file cyrkeys.bind
\bind_file greekkeys.bind

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply