In my ~/.vimrc, I have a command defined approximately like this:
nnoremap <expr> <Leader>n ':new ~/Notes/' . strftime('%F') . '-'
It is designed for creating notes files that contain the current date in the filename. The keybinding is designed to leave my cursor on the command line so that I can type the topic of the note and hit Return.
This works from within vim fine. However, I am also trying to specify a terminal command that I can use to open vim and then fire this command. I've tried:
vim -c '\n'
(my Leader is set to the default of \, which I would prefer not to change)
However, this doesn't work - instead I just get Error detected while processing command line: E10: \ should be followed by /, ? or &. I'm not sure if this is a bug in vim or if I'm doing something wrong. I also tried:
vim -c '<Leader>n'
But this gives: Error detected while processing command line: E488: Trailing characters: n Press ENTER or type command to continue.
Is there a way to achieve what I want?
nnoremap <Leader>x ':new ~/Desktop/x.txt'to remove thevim -c 'execute "normal \\x"'gives "Error detected while processing command line: E78: Unknown mark". Any thoughts why?VimEnterautocmd or some such? ... I don't have time to investigate right now, if no one else comes up with an answer this evening, I'll look into it (I'll leave this answer to be for the time), because this seems like a sort if thing I would want to have/use as well :-) – Martin Tournoij Feb 16 '15 at 13:39