]> 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:

Add support for opening links in tabs and splits
authorcodybuell <cody@codybuell.com>
Fri, 27 Apr 2018 18:29:40 +0000 (14:29 -0400)
committercodybuell <cody@codybuell.com>
Wed, 6 Jun 2018 11:26:40 +0000 (07:26 -0400)
README.md
doc/vim-markdown.txt
ftplugin/markdown.vim

index 8c056ce0c6a273676e4b431e81dbf4bc05a9bc77..e9966e846c84a345a8eb59fee15bbd0fe2836f15 100644 (file)
--- a/README.md
+++ b/README.md
@@ -293,6 +293,14 @@ If you would like to use a file extension other than `.md` you may do so using t
 let g:vim_markdown_auto_extension_ext = 'txt'
 ```
 
 let g:vim_markdown_auto_extension_ext = 'txt'
 ```
 
+### 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:
 ## 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'
 <
 >
   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 ~
 ===============================================================================
                                                         *vim-markdown-mappings*
 Mappings ~
index 1aa3494fd9c5f8cf7426a777e61d8a562f0056f3..d9efd3c7b539ac02a0a6bc8d9fcd854318f5d97a 100644 (file)
@@ -609,7 +609,22 @@ if !exists('*s:EditUrlUnderCursor')
                     endif
                 endif
                 let l:url = fnameescape(fnamemodify(expand('%:h').'/'.l:url.l:ext, ':.'))
                     endif
                 endif
                 let l:url = fnameescape(fnamemodify(expand('%:h').'/'.l:url.l:ext, ':.'))
-                execute 'edit' l:url
+                " 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
             endif
             if l:anchor != ''
                 silent! execute '/'.l:anchor