The following command starts macvim, opens the journal file with a pre-vimrc that sets the syntax to Markdown
$ macvim -f -c 'setf markdown' ~/Dropbox/Journal/2017.md'
However, when I used this same command in the .jrnl_config I get an error:
{
"editor": "macvim -f -c 'setf markdown'",
}
$ jrnl -1 --edit
Error detected while processing pre-vimrc command line:
E20: Mark not set
Press ENTER or type command to continue
Any suggestions on how to fix this?
Pretty sure it's happening because the command just get's split by any whitespace, including the stuff in single quotes.
https://github.com/maebert/jrnl/blob/master/jrnl/util.py#L133
Not sure of an elegant way to fix this by changing your editor value. Might try making a branch using shlex split, because it keeps the stuff in single quotes intact.
For anyone wondering, the reason this would be cool is so that you can journal with vim and have vim-pencil and goyo start automatically.
I solved this by adding a simple function to my .vimrc which sets the desired defaults for the jrnl app:
function! JrnlSettings()
set ft=pandoc
Goyo
endfunction
command! JrnlSettings call JrnlSettings()
In my case it turns on vim-pandoc for Markdown editing and Goyo for distraction-free writing. Then in your .jrnl_config you use this:
{
"editor": "macvim -f -c JrnlSettings",
}
@cecep2 We should totally get this in to the docs!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'm trying to solve a similar issue. I renamed the journals from .txt to .md and updated the .jrnl_config to point to the new path. I can edit them directly with vim /path/to/journal.md and my vim highlighting plugin works fine. The problem is if I use jrnl @tag --edit it still assumes it's text.
A temporary workaround is to set the file type manually in vim with :set ft=markdown but having to do this every time I open it is a drag.
I think the problem that the OP was seeing is vim interpreting the single quote as a jump-to-mark. The error is correctly indicating that there is no mark for _s_. But I'm baffled as to why it would happen when called from jrnl but not when called on the command line.
@BenKettlewell You should be able to automatically call :set ft=markdown on a matched path. Check the file pattern that is used when jrnl creates the temp file. I'm getting something like /tmp/jrnlXXXXXXXX.txt. So you might get by with autocmd BufRead /tmp/jrnl*.txt set ft=markdown in your .vimrc.
autocmd BufRead /tmp/jrnl*.txt set ft=markdown
@gregorybodnar , you sir have my sincerest thanks 馃挴 That worked a dream.
Happy to help. I'm tempted to work out some syntax highlighting for time and tags as well.
@gregorybodnar Syntax highlighting would be fantastic!
I think we need to rework how the editor command is executed, so that arguments are passed properly to all editors.
PRs welcome!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is duplicated by #581 but there's more conversation and a potential fix there so I'm closing this one.
Most helpful comment
I think the problem that the OP was seeing is vim interpreting the single quote as a jump-to-mark. The error is correctly indicating that there is no mark for _s_. But I'm baffled as to why it would happen when called from jrnl but not when called on the command line.
@BenKettlewell You should be able to automatically call
:set ft=markdownon a matched path. Check the file pattern that is used when jrnl creates the temp file. I'm getting something like/tmp/jrnlXXXXXXXX.txt. So you might get by withautocmd BufRead /tmp/jrnl*.txt set ft=markdownin your.vimrc.