-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.vim
More file actions
53 lines (46 loc) · 1.42 KB
/
functions.vim
File metadata and controls
53 lines (46 loc) · 1.42 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
42
43
44
45
46
47
48
49
50
51
52
53
" Status bar trailing warning
"
" return '[\s]' if trailing white space is detected
" return '' otherwise
function! StatuslineTrailingSpaceWarning()
if !exists("b:statusline_trailing_space_warning")
if !&modifiable
let b:statusline_trailing_space_warning = ''
return b:statusline_trailing_space_warning
endif
if search('\s\+$', 'nw') != 0
let b:statusline_trailing_space_warning = '[\s]'
else
let b:statusline_trailing_space_warning = ''
endif
endif
return b:statusline_trailing_space_warning
endfunction
" Removing trailing spaces from ruby files
function! RemoveTraillingSpaces()
let cursor_pos = getpos(".")
%s/[ \t]*$//g
call setpos(".", cursor_pos)
endfunction
" Rename current file
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
function! UseCtrlZ()
echo "Use C-z"
endfunction
function! SetProjectMode()
cab Wq w<Esc>:call UseCtrlZ()
cab WQ w<Esc>:call UseCtrlZ()
cab qw w<Esc>:call UseCtrlZ()
cab wq w<Esc>:call UseCtrlZ()
cab q <Esc>:call UseCtrlZ()
map <Leader>x <Esc>:w<CR><Esc> :call UseCtrlZ()<CR>
map <Leader>q <Esc>:call UseCtrlZ()<CR>
endfunction