-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
78 lines (62 loc) · 1.86 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
" .vimrc file meant to be sourced by other IDE's vim-plugins (VSCode, etc.)
" Vim's default behavior
if &compatible
set nocompatible
endif
" Some settings picked up from internet
set autoindent
set expandtab
set number
set relativenumber
set hlsearch
set incsearch
set ignorecase
set smartcase
set scrolloff=4
set backspace=indent,eol,start
set history=10000
set cursorline
set clipboard=unnamed
" remaps
let mapleader="\<Space>"
" Don't use Ex mode, use Q for formatting.
" Revert with ":unmap Q".
nnoremap Q gq
" Y to copy from cursor to $, as C and D
nnoremap Y y$
" n N J are centered
"nnoremap n nzzzv " found these two to be actually annoying
"nnoremap N Nzzzv
nnoremap J mzJ`z
" Easy window navigation
noremap <A-h> <C-w>h
noremap <A-j> <C-w>j
noremap <A-k> <C-w>k
noremap <A-l> <C-w>l
" Move selected lines up and down in Visual mode
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" delete selection and put without yanking selection
vmap <leader>p "_dP
" Open new file adjacent to current file
" also see http://vimcasts.org/episodes/the-edit-command/ for verbose version
" also note below is taken from book Practical Vim 2nd edition which should be
" update of this remap
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
map <leader>e :e %%
" Allow for easy copying and pasting
vnoremap <silent> y y`]
nnoremap <silent> p p`]
nnoremap <silent> P P`]
" Visually select the text that was last edited/pasted (Vimcast#26).
noremap gV `[v`]
" Use <C-L> to clear the highlighting of :set hlsearch.
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
" fix & command Practical Vim tip 93
nnoremap & :&&<CR>
xnoremap & :&&<CR>
" replace whatever was on the cursor
nnoremap <leader>s :%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>
" 'around document' text object
onoremap ad <cmd>normal! ggVG<cr>
xnoremap ad gg0oG$