Einfügemodus
Bewegung
hjkl
Ungeachtet dessen, was Pavel Shved sagte - dass es wahrscheinlich ratsamer ist, sich an die Esc Einfügemodus - hier ist ein Beispielsatz von Zuordnungen für die schnelle Navigation im Einfügemodus:
" provide hjkl movements in Insert mode via the <Alt> modifier key
inoremap <A-h> <C-o>h
inoremap <A-j> <C-o>j
inoremap <A-k> <C-o>k
inoremap <A-l> <C-o>l
Dadurch wird Alt + h im Einfügemodus ein Zeichen nach links gehen, Alt + j nach unten und so weiter, analog zu hjkl im Normalmodus.
Sie müssen diesen Code in Ihre vimrc-Datei kopieren, damit er jedes Mal geladen wird, wenn Sie vim starten (Sie können die Datei öffnen, indem Sie :new $myvimrc
beginnend im Normalmodus).
Alle Bewegungen im Normalmodus
Da die Alt Modifikatortaste nicht standardmäßig (auf etwas Wichtiges) zugewiesen ist, können Sie auf die gleiche Weise andere (oder alle) Funktionen vom Normalmodus in den Einfügemodus ziehen. Z.B.:
Verschieben an den Anfang des aktuellen Wortes mit Alt + b :
inoremap <A-b> <C-o>b
inoremap <A-w> <C-o>w
(Andere Verwendungen von Alt im Modus Einfügen)
Es ist erwähnenswert, dass es möglicherweise bessere Verwendungsmöglichkeiten für die Alt als das Verhalten im Normalmodus zu replizieren: z.B. gibt es hier Zuordnungen für das Kopieren des Teils von der aktuellen Spalte bis zum Ende der Zeile aus einer benachbarten Zeile:
" Insert the rest of the line below the cursor.
" Mnemonic: Elevate characters from below line
inoremap <A-e>
\<Esc>
\jl
\y$
\hk
\p
\a
" Insert the rest of the line above the cursor.
" Mnemonic: Y depicts a funnel, through which the above line's characters pour onto the current line.
inoremap <A-y>
\<Esc>
\kl
\y$
\hj
\p
\a
(Ich habe \
Zeilenfortsetzung und Einrückung, um die Übersichtlichkeit zu erhöhen. Die Befehle werden so interpretiert, als wären sie in einer einzigen Zeile geschrieben).
Integrierte Hotkeys für die Bearbeitung
CTRL-H delete the character in front of the cursor (same as <Backspace>)
CTRL-W delete the word in front of the cursor
CTRL-U delete all characters in front of the cursor (influenced by the 'backspace' option)
(Es gibt keine nennenswerten integrierten Hotkeys für die Bewegung im Einfügemodus).
Referenz: :help insert-index
Befehlszeilenmodus
Dieser Satz von Zuordnungen macht die obere Alt + hjkl Bewegungen in der Befehlszeile verfügbar:
" provide hjkl movements in Command-line mode via the <Alt> modifier key
cnoremap <A-h> <Left>
cnoremap <A-j> <Down>
cnoremap <A-k> <Up>
cnoremap <A-l> <Right>
Alternativ dazu fügen diese Zuordnungen die Bewegungen sowohl im Einfügemodus als auch im Befehlszeilenmodus auf einen Schlag:
" provide hjkl movements in Insert mode and Command-line mode via the <Alt> modifier key
noremap! <A-h> <Left>
noremap! <A-j> <Down>
noremap! <A-k> <Up>
noremap! <A-l> <Right>
Die Mapping-Befehle für Ziehen von Befehlen aus dem Normalmodus in den Befehlszeilenmodus sehen etwas anders aus als die Mapping-Befehle im Einfügemodus (weil im Befehlszeilenmodus die Funktionen des Einfügemodus fehlen). Ctrl + O ):
" Normal mode command(s) go… --v <-- here
cnoremap <expr> <A-h> &cedit. 'h' .'<C-c>'
cnoremap <expr> <A-j> &cedit. 'j' .'<C-c>'
cnoremap <expr> <A-k> &cedit. 'k' .'<C-c>'
cnoremap <expr> <A-l> &cedit. 'l' .'<C-c>'
cnoremap <expr> <A-b> &cedit. 'b' .'<C-c>'
cnoremap <expr> <A-w> &cedit. 'w' .'<C-c>'
Integrierte Hotkeys für Bewegung und Bearbeitung
CTRL-B cursor to beginning of command-line
CTRL-E cursor to end of command-line
CTRL-F opens the command-line window (unless a different key is specified in 'cedit')
CTRL-H delete the character in front of the cursor (same as <Backspace>)
CTRL-W delete the word in front of the cursor
CTRL-U delete all characters in front of the cursor
CTRL-P recall previous command-line from history (that matches pattern in front of the cursor)
CTRL-N recall next command-line from history (that matches pattern in front of the cursor)
<Up> recall previous command-line from history (that matches pattern in front of the cursor)
<Down> recall next command-line from history (that matches pattern in front of the cursor)
<S-Up> recall previous command-line from history
<S-Down> recall next command-line from history
<PageUp> recall previous command-line from history
<PageDown> recall next command-line from history
<S-Left> cursor one word left
<C-Left> cursor one word left
<S-Right> cursor one word right
<C-Right> cursor one word right
<LeftMouse> cursor at mouse click
Referenz: :help ex-edit-index