Setting starting cursor position in vim when replying in neomutt

404 views Asked by At

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?

2

There are 2 answers

1
ploth On BEST ANSWER

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")
0
B Phillips On

In using this line from above:

autocmd FileType mail execute "normal /^\n<CR>o"

For some reason, the end part "<CR>o" wasn't putting me into insert mode, so this worked for me:

autocmd FileType mail execute "normal /^$<CR>o" | startinsert

This gets me to the end of the headers in a new message or a reply. Note, my signature is source from a file and already includes a blank line above the signature.