alpha
Login
or
Join now
j3s.sh
/
dotfiles
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
my dotz
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
Sane vim config & bitquabit
author
Jesse Olson
date
5 years ago
(Aug 3, 2020, 10:11 PM UTC)
commit
18f026fa
18f026fad0b8bac662b5d470d7b4887e39fd9480
parent
6a0c527f
6a0c527f59c89b5fe950689875a528175ec8960b
+356
-153
2 changed files
Expand all
Collapse all
Unified
Split
.config
rss-feeds.txt
.vimrc
+1
.config/rss-feeds.txt
Reviewed
···
11
11
https://puri.sm/feed
12
12
https://blog.tildes.net/all.atom.xml
13
13
https://100r.co/links/rss.xml
14
14
+
https://www.bitquabit.com/index.xml
+355
-153
.vimrc
Reviewed
···
1
1
-
set nocompatible
2
2
-
filetype off
1
1
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2
2
+
" Maintainer:
3
3
+
" Amir Salihefendic — @amix3k
4
4
+
"
5
5
+
" Awesome_version:
6
6
+
" Get this config, nice color schemes and lots of plugins!
7
7
+
"
8
8
+
" Install the awesome version from:
9
9
+
"
10
10
+
" https://github.com/amix/vimrc
11
11
+
"
12
12
+
" Sections:
13
13
+
" -> General
14
14
+
" -> VIM user interface
15
15
+
" -> Colors and Fonts
16
16
+
" -> Files and backups
17
17
+
" -> Text, tab and indent related
18
18
+
" -> Visual mode related
19
19
+
" -> Moving around, tabs and buffers
20
20
+
" -> Status line
21
21
+
" -> Editing mappings
22
22
+
" -> vimgrep searching and cope displaying
23
23
+
" -> Spell checking
24
24
+
" -> Misc
25
25
+
" -> Helper functions
26
26
+
"
27
27
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3
28
4
4
-
set rtp+=~/.vim/bundle/Vundle.vim
5
5
-
call vundle#begin()
6
29
7
7
-
" Bundles
8
8
-
" Actual plugins
9
9
-
Plugin 'VundleVim/Vundle.vim'
10
10
-
Plugin 'tpope/vim-fugitive'
11
11
-
Plugin 'kien/ctrlp.vim'
12
12
-
Plugin 'tpope/vim-surround'
13
13
-
Plugin 'tpope/vim-repeat'
14
14
-
Plugin 'editorconfig/editorconfig-vim'
15
15
-
Plugin 'gerw/vim-HiLinkTrace'
16
16
-
" Meta plugins
17
17
-
Plugin 'vim-scripts/ingo-library'
18
18
-
Plugin 'vim-scripts/SyntaxRange'
19
19
-
" Syntax highlighting
20
20
-
Plugin 'plasticboy/vim-markdown'
21
21
-
Plugin 'cespare/vim-toml'
22
22
-
Plugin 'rust-lang/rust.vim'
23
23
-
Plugin 'mxw/vim-jsx'
24
24
-
Plugin 'pangloss/vim-javascript'
25
25
-
Plugin 'kchmck/vim-coffee-script'
26
26
-
Plugin 'google/vim-jsonnet'
27
27
-
Plugin 'sirtaj/vim-openscad'
28
28
-
Plugin 'leafgarland/typescript-vim'
29
29
-
Plugin 'beyondmarc/glsl.vim'
30
30
-
Plugin 'vim-scripts/scons.vim'
31
31
-
Plugin 'calviken/vim-gdscript3'
32
32
-
Plugin 'wannesm/wmgraphviz.vim'
33
33
-
Plugin 'sotte/presenting.vim'
34
34
-
Plugin 'ziglang/zig.vim'
35
35
-
Plugin 'gpanders/vim-scdoc'
36
36
-
" /Bundles
30
30
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
31
31
+
" => General
32
32
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
33
33
+
" Sets how many lines of history VIM has to remember
34
34
+
set history=500
35
35
+
36
36
+
" Enable filetype plugins
37
37
+
filetype plugin on
38
38
+
filetype indent on
39
39
+
40
40
+
" Set to auto read when a file is changed from the outside
41
41
+
set autoread
42
42
+
au FocusGained,BufEnter * checktime
43
43
+
44
44
+
" With a map leader it's possible to do extra key combinations
45
45
+
" like <leader>w saves the current file
46
46
+
let mapleader = ","
47
47
+
48
48
+
" Fast saving
49
49
+
nmap <leader>w :w!<cr>
37
50
38
38
-
call vundle#end()
51
51
+
" :W sudo saves the file
52
52
+
" (useful for handling the permission-denied error)
53
53
+
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
39
54
40
40
-
filetype plugin indent on
41
55
42
42
-
set laststatus=2
43
43
-
set t_Co=256
56
56
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
57
57
+
" => VIM user interface
58
58
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
59
59
+
" Set 7 lines to the cursor - when moving vertically using j/k
60
60
+
set so=7
44
61
45
45
-
let g:vim_markdown_folding_disabled=1
46
46
-
let g:vim_markdown_frontmatter=1
47
47
-
let g:jsx_ext_required = 0
62
62
+
" Avoid garbled characters in Chinese language windows OS
63
63
+
let $LANG='en'
64
64
+
set langmenu=en
65
65
+
source $VIMRUNTIME/delmenu.vim
66
66
+
source $VIMRUNTIME/menu.vim
48
67
49
49
-
set encoding=utf-8
50
50
-
set tabstop=4
51
51
-
set shiftwidth=4
52
52
-
set autoindent
53
53
-
set magic " unbreak vim's regex implementation
68
68
+
" Turn on the Wild menu
69
69
+
set wildmenu
54
70
55
55
-
set number
56
56
-
set scrolloff=3
57
57
-
set sidescroll=3
71
71
+
" Ignore compiled files
72
72
+
set wildignore=*.o,*~,*.pyc
73
73
+
if has("win16") || has("win32")
74
74
+
set wildignore+=.git\*,.hg\*,.svn\*
75
75
+
else
76
76
+
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
77
77
+
endif
58
78
79
79
+
"Always show current position
59
80
set ruler
60
60
-
set cc=80
61
61
-
set nowrap
81
81
+
82
82
+
" Height of the command bar
83
83
+
set cmdheight=1
84
84
+
85
85
+
" A buffer becomes hidden when it is abandoned
86
86
+
set hid
62
87
88
88
+
" Configure backspace so it acts as it should act
89
89
+
set backspace=eol,start,indent
90
90
+
set whichwrap+=<,>,h,l
91
91
+
92
92
+
" Ignore case when searching
63
93
set ignorecase
64
64
-
set smartcase
65
94
66
66
-
set splitbelow
67
67
-
set hidden
68
68
-
set notimeout
95
95
+
" When searching try to be smart about cases
96
96
+
set smartcase
69
97
70
70
-
" Search as you type, highlight results
71
71
-
set incsearch
72
72
-
set showmatch
98
98
+
" Highlight search results
73
99
set hlsearch
74
100
75
75
-
" eff mouz
76
76
-
set mouse=a
101
101
+
" Makes search act like search in modern browsers
102
102
+
set incsearch
77
103
78
78
-
" Don't litter swp files everywhere
79
79
-
set backupdir=~/.cache
80
80
-
set directory=~/.cache
104
104
+
" Don't redraw while executing macros (good performance config)
105
105
+
set lazyredraw
81
106
82
82
-
set nofoldenable
83
83
-
set lazyredraw
107
107
+
" For regular expressions turn magic on
108
108
+
set magic
84
109
85
85
-
set tags=./tags;
110
110
+
" Show matching brackets when text indicator is over them
111
111
+
set showmatch
112
112
+
" How many tenths of a second to blink when matching brackets
113
113
+
set mat=2
86
114
87
87
-
set printheader=\
115
115
+
" No annoying sound on errors
116
116
+
set noerrorbells
117
117
+
set novisualbell
118
118
+
set t_vb=
119
119
+
set tm=500
88
120
89
89
-
syntax on
90
90
-
let mapleader = "\<space>"
91
91
-
nnoremap \\ :noh<cr> " Clear higlighting
92
92
-
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR> " Trim trailing spaces
93
93
-
nnoremap Y y$
94
94
-
nnoremap cc :center<cr>
95
95
-
inoremap <C-c> <ESC>
96
96
-
" Ex mode is fucking dumb
97
97
-
nnoremap Q <Nop>
121
121
+
" Properly disable sound on errors on MacVim
122
122
+
if has("gui_macvim")
123
123
+
autocmd GUIEnter * set vb t_vb=
124
124
+
endif
98
125
99
99
-
command Jp e ++enc=euc-jp
100
126
101
101
-
" Preferences for various file formats
102
102
-
autocmd FileType c setlocal noet ts=4 sw=4 tw=80
103
103
-
autocmd FileType h setlocal noet ts=4 sw=4 tw=80
104
104
-
autocmd FileType cpp setlocal noet ts=4 sw=4 tw=80
105
105
-
autocmd FileType s setlocal noet ts=4 sw=4
106
106
-
autocmd FileType go setlocal noet ts=4 sw=4
107
107
-
autocmd FileType hy setlocal filetype=lisp
108
108
-
autocmd FileType sh setlocal noet ts=4 sw=4
109
109
-
autocmd BufRead,BufNewFile *.js setlocal et ts=2 sw=2
110
110
-
autocmd FileType html setlocal et ts=2 sw=2
111
111
-
autocmd FileType htmldjango setlocal et ts=2 sw=2
112
112
-
autocmd FileType ruby setlocal et ts=2 sw=2
113
113
-
autocmd FileType scss setlocal et ts=2 sw=2
114
114
-
autocmd FileType yaml setlocal et ts=2 sw=2
115
115
-
autocmd FileType markdown setlocal tw=80 et ts=2 sw=2
116
116
-
autocmd FileType text setlocal tw=80
117
117
-
autocmd FileType meson setlocal noet ts=2 sw=2
118
118
-
autocmd FileType bzl setlocal et ts=2 sw=2
119
119
-
autocmd FileType typescript setlocal et ts=2 sw=2
120
120
-
autocmd FileType python setlocal et ts=4 sw=4
121
121
-
autocmd BufNewFile,BufRead *.ms set syntax=python ts=4 sw=4 noet
122
122
-
autocmd FileType tex hi Error ctermbg=NONE
123
123
-
autocmd FileType mail setlocal noautoindent
124
124
-
augroup filetypedetect
125
125
-
autocmd BufRead,BufNewFile *mutt-* setfiletype mail
126
126
-
augroup filetypedetect
127
127
-
autocmd BufRead,BufNewFile *qutebrowser-editor-* set ts=4 sw=4 et
128
128
-
autocmd BufNewFile,BufRead * if expand('%:t') == 'APKBUILD' | set ft=sh | endif
129
129
-
autocmd BufNewFile,BufRead * if expand('%:t') == 'PKGBUILD' | set ft=sh | endif
127
127
+
" Add a bit extra margin to the left
128
128
+
set foldcolumn=1
130
129
131
131
-
set guioptions-=m
132
132
-
set guioptions-=T
133
133
-
set guioptions-=r
134
134
-
set guioptions-=e
135
130
136
136
-
nmap <leader>l :set list!<CR>
137
137
-
set listchars=tab:▸\ ,eol:¬,space:.
131
131
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
132
132
+
" => Colors and Fonts
133
133
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
134
134
+
" Enable syntax highlighting
135
135
+
syntax enable
138
136
139
139
-
syntax enable
140
140
-
colorscheme ron
141
141
-
highlight Search ctermbg=12
142
142
-
highlight NonText ctermfg=darkgrey
143
143
-
highlight SpecialKey ctermfg=darkgrey
144
144
-
highlight clear SignColumn
145
145
-
highlight Comment cterm=bold ctermfg=none
146
146
-
highlight StatusLine cterm=none ctermbg=none ctermfg=darkgrey
147
147
-
highlight StatusLineNC cterm=none ctermbg=none ctermfg=darkgrey
148
148
-
highlight Title cterm=none ctermfg=darkgrey
149
149
-
highlight TabLineFill cterm=none
150
150
-
highlight TabLine cterm=none ctermfg=darkgrey ctermbg=none
151
151
-
highlight ColorColumn ctermbg=darkgrey guibg=lightgrey
152
152
-
highlight jsParensError ctermbg=NONE
153
153
-
highlight Todo ctermbg=NONE ctermfg=red cterm=bold
154
154
-
highlight PreProc ctermfg=grey
155
155
-
highlight String ctermfg=darkblue cterm=italic
156
156
-
highlight Type ctermfg=darkblue
157
157
-
highlight lineNr ctermfg=grey cterm=italic
158
158
-
highlight cIncluded ctermfg=NONE cterm=bold
159
159
-
highlight pythonInclude ctermfg=blue
160
160
-
highlight pythonConditional ctermfg=darkcyan
161
161
-
highlight pythonBuiltin ctermfg=darkcyan
162
162
-
highlight Pmenu ctermbg=white ctermfg=black
163
163
-
highlight PmenuSel ctermbg=darkcyan ctermfg=black
137
137
+
" Enable 256 colors palette in Gnome Terminal
138
138
+
if $COLORTERM == 'gnome-terminal'
139
139
+
set t_Co=256
140
140
+
endif
164
141
165
165
-
" Transparent editing of gpg encrypted files.
166
166
-
" By Wouter Hanegraaff
167
167
-
augroup encrypted
168
168
-
au!
169
169
-
autocmd BufReadPre,FileReadPre *.gpg set viminfo=
170
170
-
autocmd BufReadPre,FileReadPre *.gpg set noswapfile noundofile nobackup
171
171
-
autocmd BufReadPre,FileReadPre *.gpg set bin
172
172
-
autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
173
173
-
autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
174
174
-
autocmd BufReadPost,FileReadPost *.gpg set nobin
175
175
-
autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
176
176
-
autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
177
177
-
autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null
178
178
-
autocmd BufWritePost,FileWritePost *.gpg u
179
179
-
augroup END
142
142
+
try
143
143
+
colorscheme desert
144
144
+
catch
145
145
+
endtry
146
146
+
147
147
+
set background=dark
148
148
+
149
149
+
" Set extra options when running in GUI mode
150
150
+
if has("gui_running")
151
151
+
set guioptions-=T
152
152
+
set guioptions-=e
153
153
+
set t_Co=256
154
154
+
set guitablabel=%M\ %t
155
155
+
endif
156
156
+
157
157
+
" Set utf8 as standard encoding and en_US as the standard language
158
158
+
set encoding=utf8
159
159
+
160
160
+
" Use Unix as the standard file type
161
161
+
set ffs=unix,dos,mac
162
162
+
163
163
+
164
164
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
165
165
+
" => Files, backups and undo
166
166
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
167
167
+
" Turn backup off, since most stuff is in SVN, git etc. anyway...
168
168
+
set nobackup
169
169
+
set nowb
170
170
+
set noswapfile
171
171
+
172
172
+
173
173
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
174
174
+
" => Text, tab and indent related
175
175
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
176
176
+
" Use spaces instead of tabs
177
177
+
set expandtab
178
178
+
179
179
+
" Be smart when using tabs ;)
180
180
+
set smarttab
181
181
+
182
182
+
" 1 tab == 4 spaces
183
183
+
set shiftwidth=4
184
184
+
set tabstop=4
185
185
+
186
186
+
" Linebreak on 500 characters
187
187
+
set lbr
188
188
+
set tw=500
189
189
+
190
190
+
set ai "Auto indent
191
191
+
set si "Smart indent
192
192
+
set wrap "Wrap lines
193
193
+
194
194
+
195
195
+
""""""""""""""""""""""""""""""
196
196
+
" => Visual mode related
197
197
+
""""""""""""""""""""""""""""""
198
198
+
" Visual mode pressing * or # searches for the current selection
199
199
+
" Super useful! From an idea by Michael Naumann
200
200
+
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
201
201
+
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
202
202
+
203
203
+
204
204
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
205
205
+
" => Moving around, tabs, windows and buffers
206
206
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
207
207
+
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
208
208
+
map <space> /
209
209
+
map <C-space> ?
210
210
+
211
211
+
" Disable highlight when <leader><cr> is pressed
212
212
+
map <silent> <leader><cr> :noh<cr>
213
213
+
214
214
+
" Smart way to move between windows
215
215
+
map <C-j> <C-W>j
216
216
+
map <C-k> <C-W>k
217
217
+
map <C-h> <C-W>h
218
218
+
map <C-l> <C-W>l
219
219
+
220
220
+
" Close the current buffer
221
221
+
map <leader>bd :Bclose<cr>:tabclose<cr>gT
222
222
+
223
223
+
" Close all the buffers
224
224
+
map <leader>ba :bufdo bd<cr>
225
225
+
226
226
+
map <leader>l :bnext<cr>
227
227
+
map <leader>h :bprevious<cr>
228
228
+
229
229
+
" Useful mappings for managing tabs
230
230
+
map <leader>tn :tabnew<cr>
231
231
+
map <leader>to :tabonly<cr>
232
232
+
map <leader>tc :tabclose<cr>
233
233
+
map <leader>tm :tabmove
234
234
+
map <leader>t<leader> :tabnext
235
235
+
236
236
+
" Let 'tl' toggle between this and the last accessed tab
237
237
+
let g:lasttab = 1
238
238
+
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
239
239
+
au TabLeave * let g:lasttab = tabpagenr()
240
240
+
241
241
+
242
242
+
" Opens a new tab with the current buffer's path
243
243
+
" Super useful when editing files in the same directory
244
244
+
map <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/
245
245
+
246
246
+
" Switch CWD to the directory of the open buffer
247
247
+
map <leader>cd :cd %:p:h<cr>:pwd<cr>
248
248
+
249
249
+
" Specify the behavior when switching between buffers
250
250
+
try
251
251
+
set switchbuf=useopen,usetab,newtab
252
252
+
set stal=2
253
253
+
catch
254
254
+
endtry
180
255
181
181
-
let g:presenting_top_margin = 2
256
256
+
" Return to last edit position when opening files (You want this!)
257
257
+
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
258
258
+
259
259
+
260
260
+
""""""""""""""""""""""""""""""
261
261
+
" => Status line
262
262
+
""""""""""""""""""""""""""""""
263
263
+
" Always show the status line
264
264
+
set laststatus=2
265
265
+
266
266
+
" Format the status line
267
267
+
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
268
268
+
269
269
+
270
270
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
271
271
+
" => Editing mappings
272
272
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
273
273
+
" Remap VIM 0 to first non-blank character
274
274
+
map 0 ^
275
275
+
276
276
+
" Move a line of text using ALT+[jk] or Command+[jk] on mac
277
277
+
nmap <M-j> mz:m+<cr>`z
278
278
+
nmap <M-k> mz:m-2<cr>`z
279
279
+
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
280
280
+
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
281
281
+
282
282
+
if has("mac") || has("macunix")
283
283
+
nmap <D-j> <M-j>
284
284
+
nmap <D-k> <M-k>
285
285
+
vmap <D-j> <M-j>
286
286
+
vmap <D-k> <M-k>
287
287
+
endif
288
288
+
289
289
+
" Delete trailing white space on save, useful for some filetypes ;)
290
290
+
fun! CleanExtraSpaces()
291
291
+
let save_cursor = getpos(".")
292
292
+
let old_query = getreg('/')
293
293
+
silent! %s/\s\+$//e
294
294
+
call setpos('.', save_cursor)
295
295
+
call setreg('/', old_query)
296
296
+
endfun
297
297
+
298
298
+
if has("autocmd")
299
299
+
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
300
300
+
endif
301
301
+
302
302
+
303
303
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
304
304
+
" => Spell checking
305
305
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
306
306
+
" Pressing ,ss will toggle and untoggle spell checking
307
307
+
map <leader>ss :setlocal spell!<cr>
308
308
+
309
309
+
" Shortcuts using <leader>
310
310
+
map <leader>sn ]s
311
311
+
map <leader>sp [s
312
312
+
map <leader>sa zg
313
313
+
map <leader>s? z=
314
314
+
315
315
+
316
316
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
317
317
+
" => Misc
318
318
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
319
319
+
" Remove the Windows ^M - when the encodings gets messed up
320
320
+
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
321
321
+
322
322
+
" Quickly open a buffer for scribble
323
323
+
map <leader>q :e ~/buffer<cr>
324
324
+
325
325
+
" Quickly open a markdown buffer for scribble
326
326
+
map <leader>x :e ~/buffer.md<cr>
327
327
+
328
328
+
" Toggle paste mode on and off
329
329
+
map <leader>pp :setlocal paste!<cr>
330
330
+
331
331
+
332
332
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
333
333
+
" => Helper functions
334
334
+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
335
335
+
" Returns true if paste mode is enabled
336
336
+
function! HasPaste()
337
337
+
if &paste
338
338
+
return 'PASTE MODE '
339
339
+
endif
340
340
+
return ''
341
341
+
endfunction
342
342
+
343
343
+
" Don't close window, when deleting a buffer
344
344
+
command! Bclose call <SID>BufcloseCloseIt()
345
345
+
function! <SID>BufcloseCloseIt()
346
346
+
let l:currentBufNum = bufnr("%")
347
347
+
let l:alternateBufNum = bufnr("#")
348
348
+
349
349
+
if buflisted(l:alternateBufNum)
350
350
+
buffer #
351
351
+
else
352
352
+
bnext
353
353
+
endif
354
354
+
355
355
+
if bufnr("%") == l:currentBufNum
356
356
+
new
357
357
+
endif
358
358
+
359
359
+
if buflisted(l:currentBufNum)
360
360
+
execute("bdelete! ".l:currentBufNum)
361
361
+
endif
362
362
+
endfunction
363
363
+
364
364
+
function! CmdLine(str)
365
365
+
call feedkeys(":" . a:str)
366
366
+
endfunction
367
367
+
368
368
+
function! VisualSelection(direction, extra_filter) range
369
369
+
let l:saved_reg = @"
370
370
+
execute "normal! vgvy"
371
371
+
372
372
+
let l:pattern = escape(@", "\\/.*'$^~[]")
373
373
+
let l:pattern = substitute(l:pattern, "\n$", "", "")
374
374
+
375
375
+
if a:direction == 'gv'
376
376
+
call CmdLine("Ack '" . l:pattern . "' " )
377
377
+
elseif a:direction == 'replace'
378
378
+
call CmdLine("%s" . '/'. l:pattern . '/')
379
379
+
endif
380
380
+
381
381
+
let @/ = l:pattern
382
382
+
let @" = l:saved_reg
383
383
+
endfunction