aboutsummaryrefslogtreecommitdiff
path: root/base/.vimrc
diff options
context:
space:
mode:
Diffstat (limited to 'base/.vimrc')
-rw-r--r--base/.vimrc69
1 files changed, 64 insertions, 5 deletions
diff --git a/base/.vimrc b/base/.vimrc
index ebdcd21..e9d7c33 100644
--- a/base/.vimrc
+++ b/base/.vimrc
@@ -46,11 +46,11 @@ set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
-nnoremap <leader><space> :noh<cr>
+nnoremap <silent> <leader><space> :noh<cr>
" Case insensitive
-nnoremap * /\<<C-R>=expand('<cword>')<CR>\><CR>
-nnoremap # ?\<<C-R>=expand('<cword>')<CR>\><CR>
+nmap * /\<<C-R>=expand('<cword>')<CR>\><CR>
+nmap # ?\<<C-R>=expand('<cword>')<CR>\><CR>
set showmatch
nnoremap <tab> %
@@ -63,7 +63,7 @@ set wrap
"set formatoptions=tqrn1
set colorcolumn=85
set ruler
-"set number " always show line numbers
+set number
set relativenumber
set laststatus=2
set cursorline
@@ -85,6 +85,8 @@ set wildignore=*.swp,*.bak,*.pyc,*.class
set ttyfast
+hi Folded ctermbg=0 ctermfg=12
+
" Stop using arrow keys ====----
nnoremap <up> <nop>
nnoremap <down> <nop>
@@ -99,7 +101,7 @@ inoremap <right> <nop>
" nnoremap k gk
" Splits ====----
-nnoremap <leader>w <C-w>v<C-w>l split
+nnoremap <leader>w <C-w>v<C-w>l
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
@@ -141,3 +143,60 @@ vnoremap Q gq
nnoremap Q gqap
cnoremap w!! w !sudo tee % >/dev/null
+
+" helper function to toggle hex mode
+function! ToggleHex()
+ " hex mode should be considered a read-only operation
+ " save values for modified and read-only for restoration later,
+ " and clear the read-only flag for now
+ let l:modified=&mod
+ let l:oldreadonly=&readonly
+ let &readonly=0
+ let l:oldmodifiable=&modifiable
+ let &modifiable=1
+ if !exists("b:editHex") || !b:editHex
+ " save old options
+ let b:oldft=&ft
+ let b:oldbin=&bin
+ " set new options
+ setlocal binary " make sure it overrides any textwidth, etc.
+ let &ft="xxd"
+ " set status
+ let b:editHex=1
+ " switch to hex editor
+ %!xxd
+ else
+ " restore old options
+ let &ft=b:oldft
+ if !b:oldbin
+ setlocal nobinary
+ endif
+ " set status
+ let b:editHex=0
+ " return to normal editing
+ %!xxd -r
+ endif
+ " restore values for modified and read only state
+ let &mod=l:modified
+ let &readonly=l:oldreadonly
+ let &modifiable=l:oldmodifiable
+endfunction
+
+command! -bar Hexmode call ToggleHex()
+nnoremap <leader>h :Hexmode<CR>
+
+function! NumberToggle()
+ if(&relativenumber == 1)
+ set number
+ else
+ set relativenumber
+ endif
+endfunc
+
+nnoremap <leader>N :call NumberToggle()<cr>
+autocmd InsertEnter * :set number
+autocmd InsertLeave * :set relativenumber
+
+
+" To move elsewhere ====----
+au BufNewFile,BufRead *.less set filetype=less