writing sql/one liners in vim
sometimes, i find myself using vim to write long shell/ruby one liners or sql queries on multiple lines.
this is helpful for those times. it copies the visual selection to the clipboard as a joined single line (without modifying the visual selection in place).
vnoremap <silent> <Leader>y "+y:let @+ = join(map(split(@+, '\n'), 'substitute(v:val, "^\\s\\+", "", "")'), " ")<CR>
it turns this:
select
username,
machine,
count(*)
from
v$session
where
machine != 'db1'
group by
machine,
username
order by
machine
into this:
select username, machine, count(*) from v$session where machine != 'db1' group by machine, username order by machine
Written by Gino Lucero
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Viml
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#