Skip to content

Instantly share code, notes, and snippets.

@mhinz
Created January 17, 2017 14:08
Show Gist options
  • Save mhinz/6967b2d10ad0ade491c0e5fc69e95cf6 to your computer and use it in GitHub Desktop.
Save mhinz/6967b2d10ad0ade491c0e5fc69e95cf6 to your computer and use it in GitHub Desktop.
:edit ~/.vim/vimrc
:cd
:echo expand('%:.')    ->  .vim/vimrc
:echo expand('%:~')    ->  ~/.vim/vimrc
:echo expand('%:~:.')  ->  .vim/vimrc
:cd /etc
:echo expand('%:.')    ->  /Users/mhi/.vim/vimrc
:echo expand('%:~')    ->  ~/.vim/vimrc
:echo expand('%:~:.')  ->  ~/.vim/vimrc

Result:

In the first case, :. is shorter and :~:. will give you the shortest output. In the second case, :~ is shorter and :~:. will still give you the shortest output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment