aboutsummaryrefslogtreecommitdiff
path: root/vimrc
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-06-19 08:30:58 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-06-19 08:30:58 +0200
commit0bc14bee27d938a184426a3f366d793aafb16e5d (patch)
treef18b7d4df783047c5a72ea4fae377b4952181c90 /vimrc
parentcfb24588aa9c6986032d4a0ee2908f9a23ed9f9e (diff)
downloaddotfiles-0bc14bee27d938a184426a3f366d793aafb16e5d.tar.gz
Fixed uncommenting and added code formatters
Diffstat (limited to 'vimrc')
-rw-r--r--vimrc20
1 files changed, 13 insertions, 7 deletions
diff --git a/vimrc b/vimrc
index ac1e2cb..84b28d6 100644
--- a/vimrc
+++ b/vimrc
@@ -1,13 +1,12 @@
1set nocompatible 1set nocompatible
2set path+=**
3set number relativenumber autoindent 2set number relativenumber autoindent
4set smartcase ignorecase incsearch 3set ignorecase smartcase incsearch
5set hidden nowrap nobackup noswapfile autoread 4set hidden nowrap nobackup noswapfile autoread
6set wildmenu laststatus=2 5set wildmenu laststatus=2
7set encoding=utf8 spelllang=en_us 6set encoding=utf8 spelllang=en_us
8set backspace=2 scrolloff=4 7set backspace=2 scrolloff=4
9set shiftwidth=4 tabstop=4 8set shiftwidth=4 tabstop=4
10set gp=grep\ -irn 9set path+=** gp=grep\ -irn
11 10
12filetype plugin indent on 11filetype plugin indent on
13syntax enable 12syntax enable
@@ -29,10 +28,17 @@ augroup commenting_blocks_of_code
29 autocmd FileType vim let b:comment_leader = '" ' 28 autocmd FileType vim let b:comment_leader = '" '
30augroup END 29augroup END
31noremap <silent> cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR> 30noremap <silent> cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
32noremap <silent> cu :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR> 31noremap <silent> cu :<C-B>silent <C-E>s/^\(\s*\)\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
33 32
34" Personal tabs/spaces settings. 33" Personal tabs/spaces settings.
35autocmd Filetype make,go setlocal noexpandtab tabstop=4 shiftwidth=4 34autocmd Filetype make,go,sh setlocal noexpandtab tabstop=4 shiftwidth=4
36autocmd Filetype c,cpp,sh,lua setlocal expandtab tabstop=4 shiftwidth=4 35autocmd Filetype c,cpp,lua setlocal expandtab tabstop=4 shiftwidth=4
37autocmd Filetype html,javascript,css setlocal expandtab tabstop=2 shiftwidth=2 36autocmd Filetype nix,html,javascript,css setlocal expandtab tabstop=2 shiftwidth=2
37
38" Function to auto format source code files.
39function! Format()
40 if &filetype == 'c' | call system('clang-format -i '.expand('%')) | edit! | endif
41 if &filetype == 'go' | call system('go fmt '.expand('%')) | edit! | endif
42endfunction
43command! Format call Format()
38 44