فهرست منبع

Add a mapping to open a file in the preview window (Contributed by Ingo Karkat)

Yegappan Lakshmanan 12 سال پیش
والد
کامیت
7750d82024
1فایلهای تغییر یافته به همراه15 افزوده شده و 4 حذف شده
  1. 15 4
      plugin/mru.vim

+ 15 - 4
plugin/mru.vim

@@ -1,7 +1,7 @@
 " File: mru.vim
 " Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
-" Version: 3.7
-" Last Modified: December 22, 2013
+" Version: 3.8
+" Last Modified: December 24, 2013
 " Copyright: Copyright (C) 2003-2013 Yegappan Lakshmanan
 " License:   Permission is hereby granted to use and distribute this code,
 "            with or without modifications, provided that this copyright
@@ -511,8 +511,7 @@ endfunction
 "               'edit' - Edit the file as a regular file
 "   multi     : Specifies  whether a single file or multiple files need to be
 "               opened.
-"   open_type : Specifies where to open the file. Can be one of 'useopen' or
-"               'newwin' or 'newtab'.
+"   open_type : Specifies where to open the file.
 "               useopen - If the file is already present in a window, then
 "                         jump to that window.  Otherwise, open the file in
 "                         the previous window.
@@ -520,6 +519,7 @@ endfunction
 "               newwin_vert - Open the file in a new vertical window.
 "               newtab  - Open the file in a new tab. If the file is already
 "                         opened in a tab, then jump to that tab.
+"               preview - Open the file in the preview window
 function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type)
     let esc_fname = s:MRU_escape_filename(a:fname)
 
@@ -535,6 +535,9 @@ function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type)
         exe 'belowright vnew ' . esc_fname
     elseif a:open_type ==# 'newtab' || g:MRU_Open_File_Use_Tabs
 	call s:MRU_Open_File_In_Tab(a:fname, esc_fname)
+    elseif a:open_type ==# 'preview'
+        " Edit the file in the preview window
+        exe 'topleft pedit ' . esc_fname
     else
         " If the selected file is already open in one of the windows,
         " jump to it
@@ -750,6 +753,14 @@ function! s:MRU_Open_Window(...)
                 \ :call <SID>MRU_Select_File_Cmd('edit,newtab')<CR>
     nnoremap <buffer> <silent> v
                 \ :call <SID>MRU_Select_File_Cmd('view,useopen')<CR>
+    nnoremap <buffer> <silent> p
+                \ :call <SID>MRU_Select_File_Cmd('view,preview')<CR>
+    vnoremap <buffer> <silent> p
+                \ :<C-u>if line("'<") == line("'>")<Bar>
+                \     call <SID>MRU_Select_File_Cmd('open,preview')<Bar>
+                \ else<Bar>
+                \     echoerr "Only a single file can be previewed"<Bar>
+                \ endif<CR>
     nnoremap <buffer> <silent> u :MRU<CR>
     nnoremap <buffer> <silent> <2-LeftMouse>
                 \ :call <SID>MRU_Select_File_Cmd('edit,useopen')<CR>