Vim command current file




















The above commands insert the output of the date program after the current line. If wanted, the!! That way a string of the form Aug 13, is embedded in the text, and it will be updated to the current date and time automatically, every time the file is saved the Calling histdel removes timestamp search pattern from search history. With the code below in your vimrc , enter :UpdateTimestamps to update the value to the current time in each instance of a tag with the format shown above.

It is not necessary to type the full command: just type :Up then press Tab for command completion. Using a command allows updating to be easily applied to multiple buffers , for example, entering :bufdo UpdateTimestamps would update all tags in all buffers. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.

Linked Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings.

You can use :! The name of the file without the extension. CharlesL CharlesL 4 4 silver badges 8 8 bronze badges. Community Bot 1. This is the same answer as the one made by thameera on the same question. There are aleady better answers, but if for some reason you wanted to use the shell to get the full path of the file this is more useful if you're going to perform some other operation on the file with the shell , on a Unix-like system you could run: :!

A realworld example might be if you're editing a config file, but don't have write permissions and don't want ot run Vim as root , you could edit the file, then run: :w! Sam Whited Sam Whited 5 5 bronze badges. To show the full path for all files, including resolved symlinks, use the following. The following will display the path relative to your current directory : :f[ile] That is :f or :file.

Simple and useful — Morteza Ziyae. Lua with nvim I wrote this function to get the full path of my current directory and then mapped it to the lualine any status line is the same.

Terrible name any suggestions? Dr Neo Dr Neo 3 3 bronze badges. Linux can try realpath command. Pegasus Pegasus 2 2 bronze badges. This only works for Linux. Welcome to Vi and Vim! Consider adding a caveat by edit ing your answer — D. You can also change the directory only for the current window each window has a local current directory that can be different from Vim's global current directory :.

Sometimes it is helpful if your working directory is always the same as the file you are editing. To achieve this, put the following in your vimrc:. That's it! Unfortunately, when this option is set some plugins may not work correctly if they make assumptions about the current directory.

Sometimes, as an alternative to setting autochdir , the following command gives better results:. This autocmd changes the window-local current directory to be the same as the directory of the current file. It fails silently to prevent error messages when you edit files via ftp or new files. It works better in some cases because the autocmd is not nested, and will therefore not fire when switching buffers via another autocmd.

It will also work in older versions of Vim or versions compiled without the 'autochdir' option.



0コメント

  • 1000 / 1000