Created
August 4, 2021 06:50
-
-
Save lukasjoc/25b22ddb670c7eb64ed7c8d477df1191 to your computer and use it in GitHub Desktop.
Set Commenting and FileTypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if has('autocmd') | |
" Commenting | |
augroup comment | |
au FileType c,cpp,rust,javascript,java,pde,scala,go,php,v,sv,proto let b:comment_leader = "// " | |
au FileType sh,yml,yaml,bash,python,pyx,nim let b:comment_leader = "# " | |
au FileType vim let b:comment_leader = '" ' | |
au FileType tex let b:comment_leader = "% " | |
au FileType sql let b:comment_leader = "-- " | |
augroup END | |
noremap <silent> ,cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,"\/")<CR>/<CR>:nohlsearch<CR> | |
noremap <silent> ,xx :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,"\/")<CR>//e<CR>:nohlsearch<CR> | |
" Setting specific filetypes | |
augroup filetypes | |
au BufRead,BufNewFile *.v,*.sv set filetype=verilog | |
au BufRead,BufNewFile *.js,*.ts,*.vue set filetype=javascript | |
au BufRead,BufNewFile *.pde set filetype=java | |
au BufRead,BufNewFile *.plist set filetype=xml | |
augroup END | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment