mru.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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: Feb 1, 2021
  5. ==============================================================================
  6. *mru-license*
  7. License: MIT License
  8. Copyright (c) 2003-2021 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 https://github.com/yegappan/mru/releases
  51. 2. Unzip the mru.zip file into the $HOME/.vim directory for Linux/MacOS/Unix
  52. systems or the $HOMEPATH/vimfiles directory for MS-Windows. After this
  53. step, you should have the following files (the directory structure should
  54. be preserved):
  55. plugin/mru.vim - MRU plugin
  56. doc/mru.txt - documentation (help) file
  57. 3. Change to the $HOME/.vim/doc or $HOME/vimfiles/doc directory, start Vim and
  58. run the ":helptags ." command to process the help file. Without this step,
  59. you cannot jump to the MRU help topics.
  60. 4. Restart Vim.
  61. 5. You can use the |:MRU| command to list and edit the recently used files.
  62. In GUI Vim, you can use the 'File->Recent Files' menu to access the
  63. recently used files.
  64. To uninstall the MRU plugin, either use the uninstall command provided by the
  65. plugin manager or manually remove the plugin/mru.vim, and doc/mru.txt
  66. files from either the $HOME/.vim or $HOME/vimfiles directory.
  67. ==============================================================================
  68. 3. Usage *mru-usage* *:MRU*
  69. To list and edit files from the Most Recently Used (MRU) list, you can use the
  70. ":MRU" command. The |:MRU| command displays the list of recently used files
  71. in a temporary Vim window. If the MRU window is already opened, then the MRU
  72. list currently displayed in the window is refreshed.
  73. If you are using GUI Vim, then the names of the recently edited files are
  74. added to the "File->Recent Files" menu. You can select the name of a file
  75. from this sub-menu to edit the file.
  76. You can use the normal Vim commands to move around in the MRU window. You
  77. cannot make changes in the MRU window.
  78. You can select a file name to edit by pressing the <Enter> key or by double
  79. clicking the left mouse button on a file name. The selected file will be
  80. opened. If the file is already opened in a window, the cursor will be moved
  81. to that window. Otherwise, the file is opened in the previous window. If the
  82. previous window has a modified buffer or is the preview window or is used by
  83. some other plugin, then the file is opened in a new window.
  84. You can press the 'o' key to open the file name under the cursor in the
  85. MRU window in a new window. You can also press <Shift-Enter> instead of 'o'
  86. to open the file in a new window.
  87. To open a file from the MRU window in read-only mode (view), press the 'v'
  88. key.
  89. To open a file from the MRU window in a new tab, press the 't' key. If the
  90. file is already opened in a window in the current or in another tab, then
  91. the cursor is moved to that tab. Otherwise, a new tab is opened.
  92. You can open multiple files from the MRU window by specifying a count before
  93. pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually (using
  94. linewise visual mode) select multiple filenames and invoke the commands to
  95. open the files. Each selected file will be opened in a separate window or
  96. tab.
  97. You can press the 'u' key in the MRU window to update the file list. This is
  98. useful if you keep the MRU window open always.
  99. You can press the 'd' key to remove the entry under the cursor in the MRU
  100. window from the MRU list.
  101. You can close the MRU window by pressing the 'q' key or the <Esc> key or
  102. using one of the Vim window commands.
  103. By default, the MRU window is opened as the bottom-most window. If you are
  104. using Vim version 8.0 and above, then you can use command modifiers like
  105. |:topleft| or |:botright| or |:vertical| with the :MRU command to control
  106. where the window is opened. Example: >
  107. :topleft MRU " horizontally split topmost window
  108. :botright MRU " horizontally split bottommost window
  109. :vertical topleft MRU " vertically split far-left window
  110. :vertical botright MRU " vertically split far-right window
  111. <
  112. By default, the height of the MRU window is 8 or the value specified by the
  113. g:MRU_Window_Height variable. You can pass a count to the :MRU command to use
  114. a different height. Example: >
  115. :15MRU
  116. :vertical topleft 20MRU
  117. <
  118. To display only files matching a pattern from the MRU list in the MRU window,
  119. you can specify a pattern to the |:MRU| command. Example: >
  120. :MRU mystr
  121. <
  122. The above command displays only the file names containing the string "mystr"
  123. in them. When you specify a partial file name and only one matching filename
  124. is found, then the |:MRU| command will edit that file.
  125. The |:MRU| command supports command-line completion of file names from
  126. the MRU list. You can enter a partial file name and then press <Tab>
  127. or <Ctrl-D> to complete or list all the matching file names. Note that
  128. after typing the |:MRU| command, you have to enter a space before completing
  129. the file names with <Tab>.
  130. When a file supplied to the |:MRU| command is not present in the MRU list,
  131. but it is a readable file, then the file will be opened (even though it is
  132. not present in the MRU list). This is useful if you want to open a file
  133. present in the same directory as a file in the MRU list. You can use the
  134. command-line completion of the |:MRU| command to complete the full path of a
  135. file and then modify the path to open another file present in the same path.
  136. Whenever the MRU list changes, the MRU file is updated with the latest MRU
  137. list. When you have multiple instances of Vim running at the same time, the
  138. latest MRU list will show up in all the instances of Vim.
  139. The MRUFilename syntax group is used to highlight the file names in the MRU
  140. window. By default, this syntax group is linked to the Identifier highlight
  141. group. You can change the highlight group by adding the following line in
  142. your .vimrc:
  143. >
  144. highlight link MRUFileName LineNr
  145. <
  146. The MRU buffer uses the 'mru file type. You can use this file type to add
  147. custom auto commands, syntax highlighting, etc.
  148. ==============================================================================
  149. 4. Configuration *mru-configuration*
  150. By changing the following variables you can configure the behavior of this
  151. plugin. Set the following variables in your .vimrc file using the 'let'
  152. command.
  153. The list of recently edited file names is stored in the file specified by the
  154. MRU_File variable. The default setting for this variable is
  155. $HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files
  156. for MS-Windows systems. You can change this variable to point to a file by
  157. adding the following line to the .vimrc file:
  158. >
  159. let MRU_File = 'd:\myhome\_vim_mru_files'
  160. <
  161. By default, the plugin will remember the names of the last 100 used files.
  162. As you edit more files, old file names will be removed from the MRU list.
  163. You can set the 'MRU_Max_Entries' variable to remember more file names. For
  164. example, to remember 1000 most recently used file names, you can use
  165. >
  166. let MRU_Max_Entries = 1000
  167. <
  168. By default, all the edited file names are added to the MRU list. If you want
  169. to exclude file names matching a pattern, then you can set the
  170. MRU_Exclude_Files variable to a Vim regular expression. If any part of a
  171. file name matches the regular expression, then it is not added to the MRU
  172. list. By default, this variable is set to an empty string. For example, to
  173. not include files in the temporary (/tmp, /var/tmp and d:\temp) directories,
  174. you can set the MRU_Exclude_Files variable to
  175. >
  176. let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix
  177. let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows
  178. <
  179. The specified pattern should be a Vim regular expression pattern. Note that
  180. you can specify multiple patterns using '\|'.
  181. If you want to add only file names matching a pattern to the MRU list, then
  182. you can set the MRU_Include_Files variable. This variable should be set to a
  183. Vim regular expression pattern. If the regular expression matches any part
  184. of a file name, then it is added to the MRU list. For example, to add only
  185. .c and .h files to the MRU list, you can set this variable as below:
  186. >
  187. let MRU_Include_Files = '\.c$\|\.h$'
  188. <
  189. By default, MRU_Include_Files is set to an empty string and all the edited
  190. filenames are added to the MRU list. Note that you can specify multiple
  191. patterns using '\|'.
  192. The default height of the MRU window is 8. You can set the MRU_Window_Height
  193. variable to change the window height. You can also set the height of the MRU
  194. window by passing a count to the :MRU command.
  195. >
  196. let MRU_Window_Height = 15
  197. <
  198. By default, when the |:MRU| command is invoked, the MRU list will be displayed
  199. in a new window. Instead, if you want the MRU plugin to reuse the current
  200. window, then you can set the 'MRU_Use_Current_Window' variable to one.
  201. >
  202. let MRU_Use_Current_Window = 1
  203. <
  204. The MRU plugin will reuse the current window. When a file name is selected,
  205. the file is also opened in the current window.
  206. When you select a file from the MRU window, the MRU window will be
  207. automatically closed and the selected file will be opened in the previous
  208. window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU
  209. window open.
  210. >
  211. let MRU_Auto_Close = 0
  212. <
  213. If you don't use the "File->Recent Files" menu and want to disable it,
  214. then you can set the 'MRU_Add_Menu' variable to zero. By default, the
  215. menu is enabled.
  216. >
  217. let MRU_Add_Menu = 0
  218. <
  219. If too many file names are present in the MRU list, then updating the MRU
  220. menu to list all the file names makes Vim slow. To avoid this, the
  221. MRU_Max_Menu_Entries variable controls the number of file names to show in
  222. the MRU menu. By default, this is set to 10. You can change this to show
  223. more entries in the menu.
  224. >
  225. let MRU_Max_Menu_Entries = 20
  226. <
  227. If many file names are present in the MRU list, then the MRU menu is split
  228. into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names.
  229. The default setting for this is 10. You can change this to increase the
  230. number of file names displayed in a single sub-menu:
  231. >
  232. let MRU_Max_Submenu_Entries = 15
  233. <
  234. In the MRU window, the filenames are displayed in two parts. The first part
  235. contains the file name without the path and the second part contains the
  236. full path to the file in parenthesis. This format is controlled by the
  237. MRU_Filename_Format variable. If you prefer to change this to some other
  238. format, then you can modify the MRU_Filename_Format variable. For example,
  239. to display the full path without splitting it, you can set this variable
  240. as shown below:
  241. >
  242. let MRU_Filename_Format =
  243. \ {'formatter':'v:val', 'parser':'.*', 'syntax': '[^/\\]\+$'}
  244. <
  245. ==============================================================================
  246. 5. FZF Integration *mru-fzf*
  247. You can use the MRU plugin with FZF (command-line fuzzy finder). You can
  248. download and install FZF from https://github.com/junegunn/fzf.
  249. To select a file from the MRU file list using FZF, run the following command:
  250. >
  251. :FZFMru
  252. <
  253. This will invoke FZF to select a file from the MRU list.
  254. ==============================================================================
  255. vim:tw=78:ts=8:noet:ft=help: