Add Neovim config
This commit is contained in:
parent
5a2f500fca
commit
29e053af75
6 changed files with 352 additions and 103 deletions
149
.vimrc
149
.vimrc
|
|
@ -1,9 +1,24 @@
|
|||
" Visual settings
|
||||
set t_Co=16
|
||||
set bg=dark
|
||||
set number
|
||||
highlight LineNr ctermfg=darkgrey
|
||||
|
||||
" Disable beeping on console
|
||||
set belloff=all
|
||||
|
||||
" Mouse settings
|
||||
set mouse=a
|
||||
|
||||
" Line numbers
|
||||
set number
|
||||
set relativenumber
|
||||
|
||||
" Amount of screen lines that should be visible above/below the cursor
|
||||
set scrolloff=5
|
||||
|
||||
" Wrap lines at word boundaries
|
||||
set linebreak
|
||||
|
||||
" Syntax highlighting
|
||||
syntax on
|
||||
set hlsearch
|
||||
|
|
@ -12,12 +27,11 @@ set hlsearch
|
|||
set ignorecase
|
||||
set smartcase
|
||||
|
||||
" Indentation options (yeah let's switch to spaces instead of tabs I guess...)
|
||||
set autoindent
|
||||
" Indentation settings
|
||||
set smartindent
|
||||
set expandtab
|
||||
set shiftwidth=4
|
||||
set tabstop=4
|
||||
set softtabstop=4
|
||||
set softtabstop=-1
|
||||
|
||||
" Activate filetype plugin (e.g. for automatically using tabs instead of spaces in Makefiles)
|
||||
filetype plugin on
|
||||
|
|
@ -29,120 +43,49 @@ autocmd BufNewFile,BufRead *.rasi set syntax=scss
|
|||
" Indentation for YAML (use 2 spaces)
|
||||
autocmd FileType yml,yaml setlocal sts=2 sw=2
|
||||
|
||||
" Mouse settings
|
||||
set mouse=a
|
||||
|
||||
" Disable beeping on console
|
||||
set belloff=all
|
||||
|
||||
" Do not insert comment leader when entering insert mode with 'o'/'O' in comment line
|
||||
autocmd BufNewFile,BufRead * set formatoptions-=o
|
||||
|
||||
" clang autocomplete: do not open completion box automatically
|
||||
let g:clang_complete_auto=0
|
||||
|
||||
|
||||
" Disable middle mouse button paste when in normal mode
|
||||
map <MiddleMouse> <Nop>
|
||||
map <2-MiddleMouse> <Nop>
|
||||
map <3-MiddleMouse> <Nop>
|
||||
map <4-MiddleMouse> <Nop>
|
||||
|
||||
|
||||
" Keyboard mappings
|
||||
" -----------------
|
||||
nnoremap <C-L> :nohl<CR>:diffupdate<CR><C-L>
|
||||
|
||||
nnoremap <C-l> :nohl<CR>:diffupdate<CR><C-l>
|
||||
set pastetoggle=<F2>
|
||||
|
||||
" Toggle line numbers
|
||||
nnoremap <F3> :set number!<CR>
|
||||
" Exit insert mode with jk
|
||||
inoremap jk <Esc>
|
||||
|
||||
" If the current buffer has never been saved, it will have no name,
|
||||
" call the file browser to save it, otherwise just save it.
|
||||
command! -nargs=0 -bar Update if &modified
|
||||
\| if empty(bufname('%'))
|
||||
\| browse confirm write
|
||||
\| else
|
||||
\| confirm write
|
||||
\| endif
|
||||
\|endif
|
||||
" Quick exit with Ctrl-q
|
||||
nnoremap <C-q> :q<CR>
|
||||
nnoremap Q <Nop>
|
||||
|
||||
" Bind <C-S> to save
|
||||
nnoremap <silent> <C-s> :<C-u>Update<CR>
|
||||
inoremap <C-s> <C-o>:Update<CR>
|
||||
" Quick save all open buffers with Ctrl-S
|
||||
nnoremap <C-s> :wall<CR>
|
||||
inoremap <C-s> <C-o>:wall<CR>
|
||||
|
||||
" Simple copy and paste to/from system clipboard with Ctrl-c in visual mode
|
||||
" and Ctrl-v in insert mode
|
||||
vnoremap <C-c> "+y
|
||||
inoremap <C-v> <C-\><C-o>"+P
|
||||
|
||||
" sudo-write with :w!!
|
||||
cnoremap w!! w !sudo tee >/dev/null %
|
||||
|
||||
" Edit (\ev) and reload (\rv) .vimrc (reload .gvimrc if running gvim)
|
||||
nnoremap <leader>ev :split $MYVIMRC<CR>
|
||||
if has('gui_running')
|
||||
nnoremap <leader>rv :source $MYVIMRC<CR>:source $MYGVIMRC<CR>
|
||||
else
|
||||
nnoremap <leader>rv :source $MYVIMRC<CR>
|
||||
endif
|
||||
|
||||
" Split line at cursor with <C-J> (as opposite of <Shift-J> for join lines)
|
||||
nnoremap <C-J> i<CR><Esc>k$
|
||||
|
||||
|
||||
" Easier buffer switching
|
||||
" -----------------------
|
||||
" Mappings to access buffers (don't use "\p" because a
|
||||
" delay before pressing "p" would accidentally paste).
|
||||
" \l : list buffers
|
||||
" \b \n \g : go back/forward/last-used
|
||||
" \1 \2 \3 : go to buffer 1/2/3 etc
|
||||
nnoremap <Leader>l :ls<CR>
|
||||
nnoremap <Leader>b :bp<CR>
|
||||
nnoremap <Leader>n :bn<CR>
|
||||
nnoremap <Leader>g :e#<CR>
|
||||
nnoremap <Leader>1 :1b<CR>
|
||||
nnoremap <Leader>2 :2b<CR>
|
||||
nnoremap <Leader>3 :3b<CR>
|
||||
nnoremap <Leader>4 :4b<CR>
|
||||
nnoremap <Leader>5 :5b<CR>
|
||||
nnoremap <Leader>6 :6b<CR>
|
||||
nnoremap <Leader>7 :7b<CR>
|
||||
nnoremap <Leader>8 :8b<CR>
|
||||
nnoremap <Leader>9 :9b<CR>
|
||||
nnoremap <Leader>0 :10b<CR>
|
||||
|
||||
" Compiling and making
|
||||
nnoremap <F9> :up<CR>:make<CR>:redraw! \| cw<CR>
|
||||
nnoremap <F10> :up<CR>:make run<CR>:redraw! \| cw<CR>
|
||||
|
||||
" Tab buffers
|
||||
nnoremap <F12> :tab ball<CR>
|
||||
|
||||
" Tab movement
|
||||
noremap <A-[> :-tabmove<CR>
|
||||
noremap <A-]> :+tabmove<CR>
|
||||
|
||||
" Use comma (,) as a "modifier prefix" for alternative functions of regular
|
||||
" commands (e.g. yank to system clipboard) or for random shortcuts.
|
||||
noremap , <Nop>
|
||||
|
||||
" -- Shortcuts for insert mode
|
||||
" Exit insert mode
|
||||
imap ,, <ESC>
|
||||
imap jk <ESC>
|
||||
inoremap <A-,> <ESC>
|
||||
|
||||
" Quick movement with Alt-h/j/k/l
|
||||
inoremap <A-h> <C-o>h
|
||||
inoremap <A-j> <C-o>j
|
||||
inoremap <A-k> <C-o>k
|
||||
inoremap <A-l> <C-o>l
|
||||
|
||||
" Unindent with Shift-Tab
|
||||
inoremap <S-Tab> <C-o><<
|
||||
|
||||
" Copy to and paste from X clipboard (Ctrl-C in visual mode and Ctrl-V in insert mode)
|
||||
vmap <C-C> "+y
|
||||
imap <C-V> <C-\><C-O>"+P
|
||||
|
||||
" Undo in insert mode with Ctrl-U
|
||||
imap <C-U> <C-O>u
|
||||
|
||||
" Quick exit
|
||||
map Q :qa<CR>
|
||||
" Because I always type q: too fast, which opens the command history...
|
||||
map q: :q
|
||||
" Prefix yank/delete/change/paste commands with "," to use system clipboard
|
||||
noremap ,y "+y
|
||||
noremap ,Y "+y$
|
||||
noremap ,d "+d
|
||||
noremap ,D "+D
|
||||
noremap ,c "+c
|
||||
noremap ,C "+C
|
||||
noremap ,p "+p
|
||||
noremap ,P "+P
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue