Move to the beginning of line while in Insert mode

前端 未结 9 635
慢半拍i
慢半拍i 2021-01-30 02:04

I know that I can use either:

  1. Home in insert mode
  2. Esc + i to exit insert mode and enter it again, effectively going to th
相关标签:
9条回答
  • 2021-01-30 02:29

    You could enter insert mode using I (capital i).

    It will put the cursor at the beginning of the line.

    Similarly you can use A to add something at the end of the line.

    Though, it does not really solve the problem of moving while already being in Insert mode.

    I have just checked help on Insert mode, there is no key combination in insert mode to move at the beginning of the line.

    Other idea : Remap a new command only in insert mode

    inoremap <C-i> <Home>

    0 讨论(0)
  • 2021-01-30 02:32

    Your best course of action is to remap the action to a different key (see How to remap <Ctrl-Home> to go to first line in file? for ideas)

    I'd think of how often I use this "feature" and map it to a keystroke accordinly

    0 讨论(0)
  • 2021-01-30 02:34

    Ctrl+O whilst in insert mode puts you in command mode for one key press only. Therefore Ctrl+O then Shift+I should accomplish what you're looking for.

    0 讨论(0)
  • 2021-01-30 02:35

    If you are using MacOS Terminal go to Preferences...>Settings>Keyboard and map the end key to Ctrl-O$ (it is displayed as \017$) and then use fn+left to simulate the end key. Do the same for the home key. Escape sequence \033[H also works for home.

    0 讨论(0)
  • 2021-01-30 02:41
    ctrl+o then 0
         |      |
      letter  number
    
    0 讨论(0)
  • 2021-01-30 02:44

    I've got Ctrl+a and Ctrl+e mapped to beginning and end of line, respectively. This matches the behavior of most bash command lines. Works well for me.

    inoremap <C-e> <Esc>A
    inoremap <C-a> <Esc>I
    
    0 讨论(0)
提交回复
热议问题