Added file-line and visual-star-search. How could I forget?
David Blume

David Blume commited on 2015-11-27 20:51:14
Showing 3 changed files, with 71 additions and 5 deletions.

... ...
@@ -0,0 +1,47 @@
1
+" Avoid installing twice or when in unsupported Vim version.
2
+if exists('g:loaded_file_line') || (v:version < 700)
3
+	finish
4
+endif
5
+let g:loaded_file_line = 1
6
+
7
+function! s:gotoline()
8
+	let file = bufname("%")
9
+
10
+	" :e command calls BufRead even though the file is a new one.
11
+	" As a workarround Jonas Pfenniger<jonas@pfenniger.name> added an
12
+	" AutoCmd BufRead, this will test if this file actually exists before
13
+	" searching for a file and line to goto.
14
+	if (filereadable(file))
15
+		return
16
+	endif
17
+
18
+	" Accept file:line:column: or file:line:column and file:line also
19
+	let names =  matchlist( file, '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$')
20
+
21
+	if empty(names)
22
+		return
23
+	endif
24
+
25
+	let file_name = names[1]
26
+	let line_num  = names[2] == ''? '0' : names[2]
27
+	let  col_num  = names[3] == ''? '0' : names[3]
28
+
29
+	if filereadable(file_name)
30
+		let l:bufn = bufnr("%")
31
+		exec ":bwipeout " l:bufn
32
+
33
+		exec "keepalt edit " . file_name
34
+		exec ":" . line_num
35
+		exec "normal! " . col_num . '|'
36
+		if foldlevel(line_num) > 0
37
+			exec "normal! zv"
38
+		endif
39
+
40
+
41
+		exec "normal! zz"
42
+	endif
43
+
44
+endfunction
45
+
46
+autocmd! BufNewFile *:* nested call s:gotoline()
47
+autocmd! BufRead *:* nested call s:gotoline()
... ...
@@ -0,0 +1,17 @@
1
+" From http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html
2
+
3
+" makes * and # work on visual mode too.
4
+function! s:VSetSearch(cmdtype)
5
+  let temp = @s
6
+  norm! gv"sy
7
+  let @/ = '\V' . substitute(escape(@s, a:cmdtype.'\'), '\n', '\\n', 'g')
8
+  let @s = temp
9
+endfunction
10
+
11
+xnoremap * :<C-u>call <SID>VSetSearch('/')<CR>/<C-R>=@/<CR><CR>
12
+xnoremap # :<C-u>call <SID>VSetSearch('?')<CR>?<C-R>=@/<CR><CR>
13
+
14
+" recursively vimgrep for word under cursor or selection if you hit leader-star
15
+nmap <leader>* :execute 'noautocmd vimgrep /\V' . substitute(escape(expand("<cword>"), '\'), '\n', '\\n', 'g') . '/ **'<CR>
16
+vmap <leader>* :<C-u>call <SID>VSetSearch()<CR>:execute 'noautocmd vimgrep /' . @/ . '/ **'<CR>
17
+
... ...
@@ -39,11 +39,13 @@ See [config.dlma.com](http://config.dlma.com) for more.
39 39
     2. An empty .vim_undo directory
40 40
     3. .vim with the following plugins:
41 41
         1. [pathogen](https://github.com/tpope/vim-pathogen).
42
-        2. [bbye for :Bdelete](https://github.com/moll/vim-bbye).
43
-        3. [nerdtree](https://github.com/scrooloose/nerdtree).
44
-        4. [taglist](http://www.vim.org/scripts/script.php?script_id=273).
45
-        5. [vim-powerline](https://github.com/Lokaltog/vim-powerline).
46
-        6. Assorted favorite colors like [desert](https://github.com/dblume/desert.vim).
42
+        2. [vim-powerline](https://github.com/Lokaltog/vim-powerline).
43
+        3. [bbye for :Bdelete](https://github.com/moll/vim-bbye).
44
+        4. [nerdtree](https://github.com/scrooloose/nerdtree).
45
+        5. [taglist](http://www.vim.org/scripts/script.php?script_id=273).
46
+        6. [file-line](http://www.vim.org/scripts/script.php?script_id=2184).
47
+        7. [visual-star-search](http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html).
48
+        8. Assorted favorite colors like [desert](https://github.com/dblume/desert.vim).
47 49
 3. .gitconfig (but it needs vimdiff and github settings.)
48 50
 
49 51
 #### What's not installed
50 52