mru.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. *mru.txt* Plugin for accessing most recently used files
  2. Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
  3. For Vim version 7.0 and above
  4. Last change: May 15, 2020
  5. ==============================================================================
  6. *mru-license*
  7. License: MIT License
  8. Copyright (c) 2003-2018 Yegappan Lakshmanan
  9. Permission is hereby granted, free of charge, to any person obtaining a copy
  10. of this software and associated documentation files (the "Software"), to
  11. deal in the Software without restriction, including without limitation the
  12. rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  13. sell copies of the Software, and to permit persons to whom the Software is
  14. furnished to do so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  23. IN THE SOFTWARE.
  24. ==============================================================================
  25. CONTENTS~
  26. 1. Overview |mru-overview|
  27. 2. Installation |mru-installation|
  28. 3. Usage |mru-usage|
  29. 4. Configuration |mru-configuration|
  30. 5. FZF Integration |mru-fzf|
  31. ==============================================================================
  32. 1. Overview *mru-overview*
  33. The Most Recently Used (MRU) plugin provides an easy access to a list of
  34. recently opened/edited files in Vim. This plugin automatically stores the
  35. file names as you open/edit them in Vim.
  36. This plugin will work on all the platforms where Vim is supported. This
  37. plugin will work in both console and GUI Vim. This version of the MRU
  38. plugin needs Vim 7.0 and above. If you are using an earlier version of
  39. Vim, then you should use an older version of the MRU plugin.
  40. The recently used filenames are stored in a file specified by the Vim
  41. MRU_File variable.
  42. The Github repository for the MRU plugin is available at:
  43. http://github.com/yegappan/mru
  44. ==============================================================================
  45. 2. Installation *mru-installation*
  46. You can use any one of the Vim plugin managers (dein.vim, pathogen, vam,
  47. vim-plug, volt, Vundle, etc.) to install and manage this plugin.
  48. Alternatively, you can also manually download and install the plugin
  49. using the following steps.
  50. 1. Download the mru.zip file from the vim.sourceforge.io site.
  51. 2. Unzip the files into the $HOME/.vim or the $HOME/vimfiles directory. After
  52. this step, you should have the following files (the directory structure
  53. should be preserved):
  54. plugin/mru.vim - MRU plugin
  55. doc/mru.txt - documentation (help) file
  56. 3. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc or $VIM/vimfiles/doc
  57. directory, start Vim and run the ":helptags ." command to process the
  58. help file. Without this step, you cannot jump to the help topics.
  59. 4. Restart Vim.
  60. 5. You can use the |:MRU| command to list and edit the recently used files.
  61. In GUI Vim, you can use the 'File->Recent Files' menu to access the
  62. recently used files.
  63. To uninstall the MRU plugin, either use the uninstall command provided by the
  64. plugin manager or manually remove the plugin/mru.vim, and doc/greplace.txt
  65. files from the $HOME/.vim or $HOME/vimfiles directory.
  66. ==============================================================================
  67. 3. Usage *mru-usage* *:MRU*
  68. To list and edit files from the Most Recently Used (MRU) list, you can use the
  69. ":MRU" command. The |:MRU| command displays the list of recently used files
  70. in a temporary Vim window. If the MRU window is already opened, then the MRU
  71. list currently displayed in the window is refreshed.
  72. If you are using GUI Vim, then the names of the recently edited files are
  73. added to the "File->Recent Files" menu. You can select the name of a file
  74. from this sub-menu to edit the file.
  75. You can use the normal Vim commands to move around in the MRU window. You
  76. cannot make changes in the MRU window.
  77. You can select a file name to edit by pressing the <Enter> key or by double
  78. clicking the left mouse button on a file name. The selected file will be
  79. opened. If the file is already opened in a window, the cursor will be moved
  80. to that window. Otherwise, the file is opened in the previous window. If the
  81. previous window has a modified buffer or is the preview window or is used by
  82. some other plugin, then the file is opened in a new window.
  83. You can press the 'o' key to open the file name under the cursor in the
  84. MRU window in a new window. You can also press <Shift-Enter> instead of 'o'
  85. to open the file in a new window.
  86. To open a file from the MRU window in read-only mode (view), press the 'v'
  87. key.
  88. To open a file from the MRU window in a new tab, press the 't' key. If the
  89. file is already opened in a window in the current or in another tab, then
  90. the cursor is moved to that tab. Otherwise, a new tab is opened.
  91. You can open multiple files from the MRU window by specifying a count before
  92. pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually (using
  93. linewise visual mode) select multiple filenames and invoke the commands to
  94. open the files. Each selected file will be opened in a separate window or
  95. tab.
  96. You can press the 'u' key in the MRU window to update the file list. This is
  97. useful if you keep the MRU window open always.
  98. You can close the MRU window by pressing the 'q' key or the <Esc> key or
  99. using one of the Vim window commands.
  100. To display only files matching a pattern from the MRU list in the MRU
  101. window, you can specify a pattern to the |:MRU| command. For example, to
  102. display only file names matching "vim" in them, you can use the following
  103. command ":MRU vim". When you specify a partial file name and only one
  104. matching filename is found, then the |:MRU| command will edit that file.
  105. The |:MRU| command supports command-line completion of file names from
  106. the MRU list. You can enter a partial file name and then press <Tab>
  107. or <Ctrl-D> to complete or list all the matching file names. Note that
  108. after typing the |:MRU| command, you have to enter a space before completing
  109. the file names with <Tab>.
  110. When a file supplied to the |:MRU| command is not present in the MRU list,
  111. but it is a readable file, then the file will be opened (even though it is
  112. not present in the MRU list). This is useful if you want to open a file
  113. present in the same directory as a file in the MRU list. You can use the
  114. command-line completion of the |:MRU| command to complete the full path of a
  115. file and then modify the path to open another file present in the same path.
  116. Whenever the MRU list changes, the MRU file is updated with the latest MRU
  117. list. When you have multiple instances of Vim running at the same time, the
  118. latest MRU list will show up in all the instances of Vim.
  119. The MRUFilename syntax group is used to highlight the file names in the MRU
  120. window. By default, this syntax group is linked to the Identifier highlight
  121. group. You can change the highlight group by adding the following line in
  122. your .vimrc:
  123. >
  124. highlight link MRUFileName LineNr
  125. <
  126. The MRU buffer uses the 'mru file type. You can use this file type to add
  127. custom auto commands, syntax highlighting, etc.
  128. ==============================================================================
  129. 4. Configuration *mru-configuration*
  130. By changing the following variables you can configure the behavior of this
  131. plugin. Set the following variables in your .vimrc file using the 'let'
  132. command.
  133. The list of recently edited file names is stored in the file specified by the
  134. MRU_File variable. The default setting for this variable is
  135. $HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files
  136. for MS-Windows systems. You can change this variable to point to a file by
  137. adding the following line to the .vimrc file:
  138. >
  139. let MRU_File = 'd:\myhome\_vim_mru_files'
  140. <
  141. By default, the plugin will remember the names of the last 100 used files.
  142. As you edit more files, old file names will be removed from the MRU list.
  143. You can set the 'MRU_Max_Entries' variable to remember more file names. For
  144. example, to remember 1000 most recently used file names, you can use
  145. >
  146. let MRU_Max_Entries = 1000
  147. <
  148. By default, all the edited file names are added to the MRU list. If you want
  149. to exclude file names matching a pattern, then you can set the
  150. MRU_Exclude_Files variable to a Vim regular expression. If any part of a
  151. file name matches the regular expression, then it is not added to the MRU
  152. list. By default, this variable is set to an empty string. For example, to
  153. not include files in the temporary (/tmp, /var/tmp and d:\temp) directories,
  154. you can set the MRU_Exclude_Files variable to
  155. >
  156. let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix
  157. let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows
  158. <
  159. The specified pattern should be a Vim regular expression pattern. Note that
  160. you can specify multiple patterns using '\|'.
  161. If you want to add only file names matching a pattern to the MRU list, then
  162. you can set the MRU_Include_Files variable. This variable should be set to a
  163. Vim regular expression pattern. If the regular expression matches any part
  164. of a file name, then it is added to the MRU list. For example, to add only
  165. .c and .h files to the MRU list, you can set this variable as below:
  166. >
  167. let MRU_Include_Files = '\.c$\|\.h$'
  168. <
  169. By default, MRU_Include_Files is set to an empty string and all the edited
  170. filenames are added to the MRU list. Note that you can specify multiple
  171. patterns using '\|'.
  172. The default height of the MRU window is 8. You can set the MRU_Window_Height
  173. variable to change the window height.
  174. >
  175. let MRU_Window_Height = 15
  176. <
  177. By default, when the |:MRU| command is invoked, the MRU list will be displayed
  178. in a new window. Instead, if you want the MRU plugin to reuse the current
  179. window, then you can set the 'MRU_Use_Current_Window' variable to one.
  180. >
  181. let MRU_Use_Current_Window = 1
  182. <
  183. The MRU plugin will reuse the current window. When a file name is selected,
  184. the file is also opened in the current window.
  185. When you select a file from the MRU window, the MRU window will be
  186. automatically closed and the selected file will be opened in the previous
  187. window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU
  188. window open.
  189. >
  190. let MRU_Auto_Close = 0
  191. <
  192. If you don't use the "File->Recent Files" menu and want to disable it,
  193. then you can set the 'MRU_Add_Menu' variable to zero. By default, the
  194. menu is enabled.
  195. >
  196. let MRU_Add_Menu = 0
  197. <
  198. If too many file names are present in the MRU list, then updating the MRU
  199. menu to list all the file names makes Vim slow. To avoid this, the
  200. MRU_Max_Menu_Entries variable controls the number of file names to show in
  201. the MRU menu. By default, this is set to 10. You can change this to show
  202. more entries in the menu.
  203. >
  204. let MRU_Max_Menu_Entries = 20
  205. <
  206. If many file names are present in the MRU list, then the MRU menu is split
  207. into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names.
  208. The default setting for this is 10. You can change this to increase the
  209. number of file names displayed in a single sub-menu:
  210. >
  211. let MRU_Max_Submenu_Entries = 15
  212. <
  213. In the MRU window, the filenames are displayed in two parts. The first part
  214. contains the file name without the path and the second part contains the
  215. full path to the file in parenthesis. This format is controlled by the
  216. MRU_Filename_Format variable. If you prefer to change this to some other
  217. format, then you can modify the MRU_Filename_Format variable. For example,
  218. to display the full path without splitting it, you can set this variable
  219. as shown below:
  220. >
  221. let MRU_Filename_Format =
  222. \ {'formatter':'v:val', 'parser':'.*', 'syntax': '[^/\\]\+$'}
  223. <
  224. ==============================================================================
  225. 5. FZF Integration *mru-fzf*
  226. You can use the MRU plugin with FZF (command-line fuzzy finder). You can
  227. download and install FZF from https://github.com/junegunn/fzf.
  228. To select a file from the MRU file list using FZF, run the following command:
  229. >
  230. :FZFMru
  231. <
  232. This will invoke FZF to select a file from the MRU list.
  233. ==============================================================================
  234. vim:tw=78:ts=8:noet:ft=help: