Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make :SearchNotes user friendly (enable line wrapping, resize quick-f…
…ix window)

The plug-in now enables line wrapping in the quick-fix window and
resizes the quick-fix window to 1/3 of the available screen lines or the
number of screen lines in the quick-fix window, whichever is smaller.

This fixes a long standing annoyance of mine: when there are only one or
two matches the quick-fix list would open 2 lines high, but none of the
matches were actually visible because they were contained in a paragraph
of text that scrolled off the screen to the right. I would resize the
quick-fix window and enable line wrapping just to inspect the matches.
  • Loading branch information
xolox committed Nov 25, 2011
1 parent 78c4cd7 commit d1ceea3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion autoload/xolox/notes.vim
Expand Up @@ -6,7 +6,7 @@
" Note: This file is encoded in UTF-8 including a byte order mark so
" that Vim loads the script using the right encoding transparently.

let g:xolox#notes#version = '0.16.1'
let g:xolox#notes#version = '0.16.2'

function! xolox#notes#shortcut() " {{{1
" The "note:" pseudo protocol is just a shortcut for the :Note command.
Expand Down Expand Up @@ -320,6 +320,16 @@ function! xolox#notes#search(bang, input) " {{{1
call s:internal_search(a:bang, all_keywords, input, any_keyword)
if &buftype == 'quickfix'
call map(keywords, '"`" . v:val . "''"')
" Enable line wrapping in the quick-fix window.
setlocal wrap
" Resize the quick-fix window to 1/3 of the screen height.
let max_height = &lines / 3
execute 'resize' max_height
" Make it smaller if the content doesn't fill the window.
normal G$
let preferred_height = winline()
execute 'resize' min([max_height, preferred_height])
normal gg
let w:quickfix_title = printf('Notes containing the word%s %s', len(keywords) == 1 ? '' : 's',
\ len(keywords) > 1 ? (join(keywords[0:-2], ', ') . ' and ' . keywords[-1]) : keywords[0])
endif
Expand Down

0 comments on commit d1ceea3

Please sign in to comment.