-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
122 lines (90 loc) · 3.45 KB
/
vimrc
File metadata and controls
122 lines (90 loc) · 3.45 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
" disable distro customization
set nocompatible
" determine filetype by extension / contents
filetype indent plugin on
" syntax highlighting
syntax on
" better command line completion
set wildmenu
" show partial commands in the last line of the screen
set showcmd
" seach highlighting <C-L> to temp disable.
set hlsearch
" Map <C-L> (redraw screen) to also turn off search highlighting until the
" next search
" nnoremap <C-L> :nohl<CR><C-L>
" Use visual bell instead of beeping when doing something wrong
set visualbell
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
" And reset the terminal code for the visual bell. If visualbell is set, and
" this line is also included, vim will neither flash nor beep. If visualbell
" is unset, this does nothing.
set t_vb=
" Indentation settings for using 2 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set shiftwidth=2
set softtabstop=2
set expandtab
" set ls=2 " always show status line. on seconds thought, this is a silly idea
let mapleader = ","
nnoremap <leader><space> :noh<cr>
nnoremap <tab> %
vnoremap <tab> %
set wrap
set textwidth=79
set formatoptions=qrn1
set colorcolumn=80
nnoremap ; :
" Reload current file
nnoremap <leader>r :edit!
" Strip all trailing whitespace from file
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Open a new vertical 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
nnoremap <C-l> <C-w>l
map <C-t> :NERDTreeToggle<CR>
nmap <leader>a= :Tabularize /=<CR>
vmap <leader>a= :Tabularize /=<CR>
nmap <leader>a: :Tabularize /:\zs<CR>
vmap <leader>a: :Tabularize /:\zs<CR>
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
let @/=''
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'godlygeek/tabular' " Alignment of text
" Syntax highlighting
Plug 'leafgarland/typescript-vim'
Plug 'fatih/vim-go'
Plug 'kchmck/vim-coffee-script'
command -nargs=1 Sql :w | !psql "<args>" < %:t
command -nargs=1 SHql :w | !ssh hawaii psql "<args>" < %:t
fun! InsertHnPost ( arg ) "{{{
"let command='r !curl --silent "'.expand(a:arg).'" | grep storylink | sed --expression "s/.*a href=\"\([^\"]*\)\" class=\"storylink\">\([^<]*\)<.*/[\2](\1)[hn](/"'
let command='r !curl --silent "'.expand(a:arg).'" | grep storylink | sed --expression "s/.*a href=\"\([^\"]*\)\" class=\"storylink\">\([^<]*\)<.*/[\2](\1)[hn](/"'
:exe command
":exe 'r !echo "'.expand(a:arg).')"'
call append(line('.'), expand(a:arg).')')
endfunction
" curl https://news.ycombinator.com/item?id=17696023 | grep storylink | sed -e 's/.*a href="\([^"]*\)" class="storylink">\([^<]*\)<.*/\1 \2/'
"command -nargs=1 Hn :r !curl --silent "<args>" | grep storylink | sed --expression='s/.*a href="\([^"]*\)" class="storylink">\([^<]*\)<.*/\1 \2/'
command -nargs=1 Hn call InsertHnPost( '<args>' )
call plug#end()