-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.vim
More file actions
41 lines (34 loc) · 1.1 KB
/
functions.vim
File metadata and controls
41 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_
\ | diffthis | wincmd p | diffthis
command -nargs=? Help help <args> | only
command Cmake !mkdir -p build;cd build;cmake -DCMAKE_TYPE_BUILD=Debug ..;make
command -nargs=* Make make -C build <args>
command -range Copy silent <line1>,<line2>w ! copy
function HeaderToggle()
let file_path = expand("%")
let file_name = expand("%<")
let extension = split(file_path, '\.')[-1] " '\.' is how you really split on dot
let err_msg = "There is no file "
if extension == "cpp"
let next_file = join([file_name, ".h"], "")
if filereadable(next_file)
:e %<.h
else
echo join([err_msg, next_file], "")
endif
elseif extension == "h"
let next_file = join([file_name, ".cpp"], "")
if filereadable(next_file)
:e %<.cpp
else
echo join([err_msg, next_file], "")
endif
endif
endfunction
function! CleverTab()
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
return "\<Tab>"
else
return "\<C-N>"
endif
endfunction