Repository navigation
Expand file tree
/
Copy pathcommands.vim
More file actions
75 lines (70 loc) · 3.11 KB
/
Copy pathcommands.vim
File metadata and controls
75 lines (70 loc) · 3.11 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
" Colors
if exists("*synstack")
" Syntax Groups
function! s:SyntaxGroups()
return join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'))
endfunc
" Echo Syntax Group
command! EchoSyntaxGroups :echo <SID>SyntaxGroups()
" Yank Syntax Group
command! YankSyntaxGroups :let @" = <SID>SyntaxGroups()|:let @+ = @"|:echo @"
" Syntax Colors
function! s:SyntaxColors()
let syntaxcolors = 'fg:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg")
let syntaxcolors .= ' fg#:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#")
let syntaxcolors .= ' bg:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"bg")
let syntaxcolors .= ' bg#:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"bg#")
let syntaxcolors .= ' sp:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"sp")
let syntaxcolors .= ' sp#:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"sp#")
let syntaxcolors .= ' italic:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"italic")
let syntaxcolors .= ' reverse:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"reverse")
let syntaxcolors .= ' inverse:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"inverse")
let syntaxcolors .= ' standout:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"standout")
let syntaxcolors .= ' underline:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"underline")
let syntaxcolors .= ' undercurl:' . synIDattr(synIDtrans(synID(line("."),col("."),1)),"undercurl")
return syntaxcolors
endfunc
" Echo Syntax Colors
command! EchoSyntaxColors :echo <SID>SyntaxColors()
endif
" Also remember `:XtermColorTable`
command! RunHighlightTest :source $VIMRUNTIME/syntax/hitest.vim
command! RunColorTest :source $VIMRUNTIME/syntax/colortest.vim
" Quit and save contents of buffer to the clipboard
command! -bang Q
\ execute "%w !pbcopy" |
\ if <bang>1 |
\ execute "q" |
\ else |
\ execute "q<bang>" |
\ endif
" Make the current buffer a grep buffer
command! GrepBuffer :call <SID>GrepBuffer()
function s:GrepBuffer()
execute "setlocal buftype=nofile bufhidden=hide noswapfile"
if line('$') == 1
" Don't show the quickfix list if there's exactly one match
execute "cbuffer"
else
execute "cbuffer | cw"
endif
endfunction
" Populate the args list from the quickfix list
" Note that a patch was submitted that might make this feature
" command unnecessary in a future version of Vim
" Source
" http://stackoverflow.com/questions/5686206/search-replace-using-quickfix-list-in-vim
" Patch
" https://groups.google.com/forum/#!msg/vim_dev/dfyt-G6SMec/_6h8pDUpeZMJ
command! -nargs=0 -bar Qargs execute 'args ' . QuickfixFilenames()
function! QuickfixFilenames()
" Building a hash ensures we get each buffer only once
let buffer_numbers = {}
for quickfix_item in getqflist()
let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
endfor
return join(values(buffer_numbers))
endfunction
" Save and Restore Session State
command! SaveSession :mksession! ~/.vim/vim_session
command! RestoreSession :source ~/.vim/vim_session