markdown-preview.nvim icon indicating copy to clipboard operation
markdown-preview.nvim copied to clipboard

can I get a new window of browser when preview ?

Open ghost opened this issue 3 years ago • 2 comments

can I get a new window of browser when preview ??? If I open a browser window before preview markdown file, it will open a tab in current window for preview, how can I get a new window?

ghost avatar Oct 09 '22 09:10 ghost

read the readme

ThePolishHussar avatar Oct 21 '22 17:10 ThePolishHussar

Question: How can I pass CLI options to the browser, like opening in a new window?

Answer: Add the following to your NVIM init script:

  function OpenMarkdownPreview (url)
    execute "silent ! firefox --new-window " . a:url
  endfunction
  let g:mkdp_browserfunc = 'OpenMarkdownPreview'

Replace "firefox" with "chrome" if you prefer. Both browsers recognize the --new-window option.

Have a look at this part in README.md. As a macOS user, I changed the function into:

  function OpenMarkdownPreview (url)
      " open preview in new window
      execute "silent ! open -n -a 'Google Chrome' --args --new-window " . a:url
  endfunction
  let g:mkdp_browserfunc = 'OpenMarkdownPreview'

If you are a linux/windows user, you should check how to open a new window in browser from terminal/cmd and change the function content.

However, it would be even better if this preference could be used as an option for vim preview.

qizidog avatar Jun 23 '23 07:06 qizidog