I want to have a simple alias to take quick notes. Each note starts with the current date and time (ISO 8601). The alias should:
- Add the current date and time
- Position the cursor in the next line
- Switch to Insert mode
I tried to use Ex mode. So far I was able to do the following:
:i <empty line> <empty line> . :1!date --iso-8601=seconds :2
I saved it in a file so I can source it when I run Vim using the
-S option. Together with my new alias
alias log="vim .notes -S .notes-source" it works quite well.
Anyway, I'd like to improve it a bit. After the last Ex command
2, can I tell Vim to automatically go to Insert mode?
Out of curiosity, can I put multiple Ex commands in one or more
-c/--cmd options? Something like this (yep, it does not work):
vim -c "i\n\n." -c "1!date --iso-8601=seconds" -c "2"
The main problem I see is that the
i Ex command requires new lines, and I'm not sure how to add them.