]> Sergey Matveev's repositories - dotfiles.git/blobdiff - vim/.vim/autoload/whereami.vim
Vim scripts refactoring
[dotfiles.git] / vim / .vim / autoload / whereami.vim
diff --git a/vim/.vim/autoload/whereami.vim b/vim/.vim/autoload/whereami.vim
new file mode 100644 (file)
index 0000000..5b5b1d8
--- /dev/null
@@ -0,0 +1,14 @@
+function! whereami#pwdLoad()
+    let g:whereami_pwdL=trim(system("pwd -L"))
+    let g:whereami_pwdP=trim(system("pwd -P"))
+endfunction
+
+function! whereami#do(fmt) abort
+    let fullpath = expand("%:p")
+    if fullpath[:len(g:whereami_pwdP)-1] ==# g:whereami_pwdP
+        let fullpath = g:whereami_pwdL . fullpath[len(g:whereami_pwdP):]
+    endif
+    let where = printf(a:fmt, fullpath, line("."))
+    let @* = where
+    echomsg where
+endfunction