drbunsen
drbunsen

Reputation: 10689

Shortcut to open specific file in Vim?

Is there a way to configure a shortcut within my .vimrc to automatically open a specific file in a new buffer? I have a file I frequently need to access and I would like to quickly open said file in a new buffer during a coding or writing session. I am not looking for a fuzzy search such as could be achieved with Command-T or PeepOpen, but rather a fast command to open a specific file in a new buffer. Bonus points if there is a way to control the shape of the new buffer window.

Upvotes: 8

Views: 1908

Answers (3)

mrdev
mrdev

Reputation: 647

Try this:

:e $MYVIMRC

On startup, $MYVIMRC env. variable is defined where your .vimrc path is.

Upvotes: 0

Zsolt Botykai
Zsolt Botykai

Reputation: 51613

You can create a mapping like:

nmap <leader>v :e ~/.vimrc<CR>

Now if you hit \v in normal mode, it opens your .vimrc.

Note: \ is the default leader setting, you can change with

let leader="WHATEVER_KEY_PREFIX_YOU_PREFER"

in your .vimrc too.

If you want in a new buffer, just try:

nmap <leader>v :find ~/.vimrc<CR>

Upvotes: 13

Kana Natsuno
Kana Natsuno

Reputation: 1065

I use uppercase marks for frequently opened files. You can use uppercase marks as bookmarks for specific files. For example:

  • mV — bookmark the current file.
  • 'V — go to the file bookmarked by mV.

Upvotes: 4

Related Questions