Search code examples
vimmuttneomutt

Setting starting cursor position in vim when replying in neomutt


When I reply to a message in neomutt, it opens the reply text in vim, as I intended. However, the initial cursor position is at the top of the headers, "From:", "To:", "Subject:" etc, and I have to manually move to the first line of reply text. How do I configure neomutt/vim so that the cursor starts at the first line of reply text?


Solution

  • I added this to my .muttrc. The drawback is that the cursor is not at the correct position if you want to edit your text again from Compose view.

    # Start in insert mode
    set editor="nvim  \"+/^$/\" \"+nohl\" \"+ normal o\" \"+startinsert\"
    

    EDIT: As @phd mentioned in the comments this can also be implemented in vim.

    I crafted two different snippets the first one way faster.

    " Use either this
    autocmd FileType mail execute "normal /^\\n\<CR>o"
    " or this
    autocmd FileType mail call feedkeys("/^\\n\<CR>o")