[vim] Implement fast switching between source/header & shaders
This commit is contained in:
parent
3f91e5f26f
commit
278a9565e2
1 changed files with 18 additions and 0 deletions
18
vimrc
18
vimrc
|
@ -196,6 +196,8 @@ for prefix in ['i', 'n', 'v']
|
|||
execute prefix . "noremap " . key . " <Nop>"
|
||||
endfor
|
||||
endfor
|
||||
"[Switch quickly between source and header]"
|
||||
nnoremap <leader>f :e <C-r>=SwapExtension()<CR><CR>
|
||||
|
||||
|
||||
|
||||
|
@ -242,6 +244,22 @@ function! ChangeScriptMode()
|
|||
endif
|
||||
endif
|
||||
endfunction
|
||||
"[Swap file extensions, for example cpp/h]"
|
||||
"https://stackoverflow.com/a/22145246"
|
||||
function! SwapExtension()
|
||||
let [rest, ext] = [expand('%:r'), expand('%:e')]
|
||||
if ext ==? 'h'
|
||||
let ext = 'cpp'
|
||||
elseif ext ==? 'cpp'
|
||||
let ext = 'h'
|
||||
"swap between vertex and fragment shader"
|
||||
elseif ext ==? 'vsh'
|
||||
let ext = 'fsh'
|
||||
elseif ext ==? 'fsh'
|
||||
let ext = 'vsh'
|
||||
endif
|
||||
return rest . '.' . ext
|
||||
endfunction
|
||||
|
||||
" Only do this part when compiled with support for autocommands.
|
||||
if has("autocmd")
|
||||
|
|
Loading…
Reference in a new issue