Showing posts with label pager. Show all posts
Showing posts with label pager. Show all posts
Tuesday, January 13, 2009
Delete to End of Page
Typing `dL' in normal mode will delete to the end of the current page. In other words, everything visible to the bottom of the window.
Thursday, September 11, 2008
Got a Question?
I had a reader of Daily Vim contact me yesterday about the possibility of periodically submitting questions regarding Vim best practices, etc. I told him that I'm very happy to assist in answering questions any Daily Vim readers might have but if I don't know the answer, I'll post the question here anyway, so someone smarter than me can ;-).
So, if you have a question regarding Vim, Linux, scripting or something along those lines, feel free to post them under this thread or email me directly via tinymountain at gmail dot com. I'll post the question and possibly an answer to the blog, and as usual, feedback is welcome.
To kick things off, I have a question of my own. Does anybody know of a Vim plugin or some method to spontaneously highlight every other line of a file? I frequently use Vim as a pager inside of MySQL, and this would be very handy for eyeballing all the values on a specific row.
UPDATE:
I solved this problem thanks in part to an initial suggestion to use syntax highlighting to perform the highlighting. Here's my finished solution. It seems to have issues with language files with pre-existing syntax highlighting, but for it's intended purpose (use within the mysql pager), it works beautifully. Just do "pager /usr/bin/vim -R -" inside the mysql client, add the code to your vimrc, run a query and hit F2.
So, if you have a question regarding Vim, Linux, scripting or something along those lines, feel free to post them under this thread or email me directly via tinymountain at gmail dot com. I'll post the question and possibly an answer to the blog, and as usual, feedback is welcome.
To kick things off, I have a question of my own. Does anybody know of a Vim plugin or some method to spontaneously highlight every other line of a file? I frequently use Vim as a pager inside of MySQL, and this would be very handy for eyeballing all the values on a specific row.
UPDATE:
I solved this problem thanks in part to an initial suggestion to use syntax highlighting to perform the highlighting. Here's my finished solution. It seems to have issues with language files with pre-existing syntax highlighting, but for it's intended purpose (use within the mysql pager), it works beautifully. Just do "pager /usr/bin/vim -R -" inside the mysql client, add the code to your vimrc, run a query and hit F2.
hi AlternateLine ctermfg=grey ctermbg=darkblue
function! HiLine(lineno)
let tmpline = escape(getline(a:lineno), '/\[]')
exec 'syn match AlternateLine /.*' . tmpline . '.*/'
endfunction
function! DoHighlight()
global /^/if line('.')%2|call HiLine(line('.'))
normal 1G
endfunction
map <F2> :call DoHighlight()<cr>

Tuesday, June 24, 2008
MySQL Pager = Vim
When using MySQL, you can set any pager you wish using the pager command.
mysq> pager less
PAGER set to 'less'
Using Vim as your pager allows you to quickly munge query output into whatever format you want.
mysql> pager vim -
PAGER set to 'vim -'
Thanks to Jay for the tip!
mysq> pager less
PAGER set to 'less'
Using Vim as your pager allows you to quickly munge query output into whatever format you want.
mysql> pager vim -
PAGER set to 'vim -'
Thanks to Jay for the tip!
Wednesday, February 13, 2008
New Man
I read a lot of manpages, and I like to have power and flexibility when doing so. Luckily, Vim is up to the task:
My primary Desktop is a modern Linux distro, so it uses utf-8 as the locale. I added the following to my bashrc (actually zshrc, but this should work for bash as well).
function man
{
/usr/bin/man $* | col -bp | iconv -c | view -c 'set ft=man nomod nolist' -
}
If you're on an older system that doesn't use utf-8 try something like this instead:
function man
{
/usr/bin/man $* | col -b | view -c 'set ft=man nomod nolist' -
}
Note that the above functions may need to modified for your shell.
My primary Desktop is a modern Linux distro, so it uses utf-8 as the locale. I added the following to my bashrc (actually zshrc, but this should work for bash as well).
function man
{
/usr/bin/man $* | col -bp | iconv -c | view -c 'set ft=man nomod nolist' -
}
If you're on an older system that doesn't use utf-8 try something like this instead:
function man
{
/usr/bin/man $* | col -b | view -c 'set ft=man nomod nolist' -
}
Note that the above functions may need to modified for your shell.
Subscribe to:
Posts (Atom)