]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge branch 'master' into master
authorHiroshi Shirosaki <h.shirosaki@gmail.com>
Thu, 26 Jul 2018 05:36:42 +0000 (14:36 +0900)
committerGitHub <noreply@github.com>
Thu, 26 Jul 2018 05:36:42 +0000 (14:36 +0900)
README.md
doc/vim-markdown.txt
ftplugin/markdown.vim

index 037ba634efe68876f5ed3590fb0e2716bc7a1db9..bb26e05fa2b5612cf07d33d8958d845fe6dc4d4e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -309,6 +309,14 @@ well, or you will have to remove an indent each time you add a new list item:
 let g:vim_markdown_new_list_item_indent = 0
 ```
 
+### Change how to open new files
+
+By default when following a link the target file will be opened in your current buffer.  This behavior can change if you prefer using splits or tabs by using the `vim_markdown_edit_url_in` variable.  Possible values are `tab`, `vsplit`, `hsplit`, `current` opening in a new tab, vertical split, horizontal split, and current buffer respectively.  Defaults to current buffer if not set:
+
+```vim
+let g:vim_markdown_edit_url_in = 'tab'
+```
+
 ## Mappings
 
 The following work on normal and visual modes:
index 714d3a957e2ba503fd63695332994e50f8ffa4b3..9bc972c5db3cf8785143bce91edf58aa9a95e767 100644 (file)
@@ -319,6 +319,19 @@ the 'vim_markdown_auto_extension_ext' variable:
 >
   let g:vim_markdown_auto_extension_ext = 'txt'
 <
+-------------------------------------------------------------------------------
+                                                     *vim-markdown-edit-url-in*
+Change how to open new files ~
+
+By default when following a link the target file will be opened in your
+current buffer.  This behavior can change if you prefer using splits or tabs
+by using the 'vim_markdown_edit_url_in' variable.  Possible values are 'tab',
+'vsplit', 'hsplit', 'current' opening in a new tab, vertical split, horizontal
+split, and current buffer respectively.  Defaults to current buffer if not
+set:
+>
+  let g:vim_markdown_edit_url_in = 'tab'
+<
 ===============================================================================
                                                         *vim-markdown-mappings*
 Mappings ~
index 1aa3494fd9c5f8cf7426a777e61d8a562f0056f3..68d1d3d994cbbc1afd4840e1aa6fef5364e54981 100644 (file)
@@ -609,7 +609,23 @@ if !exists('*s:EditUrlUnderCursor')
                     endif
                 endif
                 let l:url = fnameescape(fnamemodify(expand('%:h').'/'.l:url.l:ext, ':.'))
-                execute 'edit' l:url
+                let l:editmethod = ''
+                " determine how to open the linked file (split, tab, etc)
+                if exists('g:vim_markdown_edit_url_in')
+                  if g:vim_markdown_edit_url_in == 'tab'
+                    let l:editmethod = 'tabnew'
+                  elseif g:vim_markdown_edit_url_in == 'vsplit'
+                    let l:editmethod = 'vsp'
+                  elseif g:vim_markdown_edit_url_in == 'hsplit'
+                    let l:editmethod = 'sp'
+                  else
+                    let l:editmethod = 'edit'
+                  endif
+                else
+                  " default to current buffer
+                  let l:editmethod = 'edit'
+                endif
+                execute l:editmethod l:url
             endif
             if l:anchor != ''
                 silent! execute '/'.l:anchor