From f244e0837b48eef2d62399a166eb36a2d68fa999 Mon Sep 17 00:00:00 2001 From: plrectco Date: Mon, 9 Dec 2019 16:47:02 -0800 Subject: [PATCH] split some function into common.vim' --- vimrcs/common.vim | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 vimrcs/common.vim diff --git a/vimrcs/common.vim b/vimrcs/common.vim new file mode 100644 index 00000000..afae30f3 --- /dev/null +++ b/vimrcs/common.vim @@ -0,0 +1,27 @@ +" Get the file path of the current citc client. +" If it is not a citc client, return the entire path. +function! GetSmartFilePath() + let path = expand('%:p:h') + " If in google3 path, display the client name and the absolute path + if matchstr(path, 'google3') == 'google3' + let output = '' + let subs = split(path, '/') + let add_to_output = 0 + let prev_s = '' + for s in subs + if add_to_output == 1 + let output .= '/' + let output .= s + endif + if s == 'google3' + let output .= prev_s + let output .= ':' + let add_to_output = 1 + endif + let prev_s = s + endfor + return output + else + return path + endif +endfunction