iamcco / markdown-preview.nvim

markdown preview plugin for (neo)vim
MIT License
6.66k stars 276 forks source link

can I get a new window of browser when preview ? #510

Open ghost opened 1 year ago

ghost commented 1 year ago

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?

ThePolishHussar commented 1 year ago

read the readme

qizidog commented 1 year ago

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.