: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.