Vim add files opened through the CLI to: e history

In Vim, by default, when you type :e and press the up arrow, it shows a list of files previously opened with the command :e . Is there any way to add the files that I opened from the terminal via vim <filename> to this list?

+6
source share
2 answers

One possibility:

 au BufEnter * for f in argv() | call histadd( "cmd", "e " . f ) | endfor 

Explanation:

 au # Autocommand. BufEnter # Run it after entering a buffer. * # For any file matching. for f in argv() # Select files in argument list. call histadd( "cmd", "e " . f ) # Append to history of ex commands (beginning # with colon) letter 'e' (of edit) with file name. endfor # Repeat next loop. 

Put this command in your vimrc file and try.

+2
source

I do not think so. :e <up> is just a convenient way to view your ex command history. This does not apply to the editing command. It just happens that when you enter the beginning of the ex command, the history will be β€œfiltered” by entries starting with the same characters.

The :args command will list the files specified as arguments in the command line and :arge edit the file and put it in the argument (if it is not already).

Alternatively, the :b command can be used to enter a buffer (in case you still have a file in the buffer and you want to edit it.

One of them can help you!

+2
source

Source: https://habr.com/ru/post/904269/


All Articles