I’m looking for something to put into the vimrc file that runs on startup. I need to check the 2nd line of the file that it opens for:
To:
That’s to and a space, basically those word’s and then nothing after it. If it finds an “empty” To: it takes me to that line at the end, line 2. If To: has text after it then it takes me to line 9.
I use Vim for editing emails in Mutt, and I’m trying to get it to decide if I’m replying to an email (the email address is already there) or creating a new email (I need to enter an address) and take me to the appropriate line.
Not quite sure where to even start with this, I don’t know if I can run function’s on startup in the vimrc and how to tell it to go to the end of X line. I know I can go to a line with:
2gg
but the end of the line and the regex is the hard part for me.
Try
. Note: it makes sense to have better detection of whether you are editing a mutt message (currently it assumes you do if you have
To:(with a space) on the second line).By the way, you need exactly no regular expressions here, Vim is not as good at optimizing them as perl.