Vim Tips Wiki
No edit summary
 
(Change to TipImported template + severe manual clean)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=555
 
|id=555
  +
|previous=554
|title=Vim as bookmark manager
 
  +
|next=556
|created=September 11, 2003 5:08
+
|created=September 11, 2003
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Mikolaj Machowski
 
|author=Mikolaj Machowski
 
|version=6.0
 
|version=6.0
 
|rating=17/10
 
|rating=17/10
 
}}
|text=
 
  +
Sometimes you are collecting bookmarks from various sources, not only web, mail client, usenet even newspapers. Sometimes it is not possible or convenient to insert them in your favorite web browser bookmark manager. But nothing is lost - you can use Vim.
Vim as bookmarks manager
 
   
 
Keep all URLs in one file called, for example, <tt>url</tt> &ndash; one URL per line.
   
 
Put this in your .vimrc:
   
  +
<pre>
Sometimes you are collecting bookmarks from various sources, not only
 
 
autocmd BufRead ~/url map &lt;F8&gt; :call BrowserURL()&lt;cr&gt;
 
let g:web_browser = "konqueror"
 
function! BrowserURL()
 
if getline('.') !~ '^\s*\#'
 
if g:web_browser == "konqueror"
 
exe ":!dcop `dcopfind -a 'konqueror*'` konqueror-mainwindow\\#1 newTab ".getline('.')
 
elseif g:web_browser == "mozilla"
 
exe ":!mozilla -remote \"openurl(".getline('.').", new-tab)\""
  +
endif
  +
endif
 
endfunction
  +
</pre>
   
  +
Use visual mode to select one or more lines, then press a key to open the URLs in tabs. Any line starting with '#' is a comment and is skipped.
web, mail client, usenet even newspapers. Sometimes it is not possible, easy etc.
 
   
 
I am sure such operation are possible also with other web browsers with tabs.
to insert them in your favorite web browser bookmark manager. But
 
   
 
Konqueror from KDE3.2-Alpha1 (but this dcop commands should work also with older versions)
nothing is lost - you can use your Editor :)
 
   
 
Mozilla 1.4
   
 
==Comments==
   
  +
----
Keep all URLs in one file called eg. url. One URL per line.
 
 
Put this in your .vimrc:
 
 
 
 
autocmd BufRead ~/url map &lt;F8&gt; :call BrowserURL()&lt;cr&gt;
 
 
let g:web_browser = "konqueror"
 
 
function! BrowserURL()
 
 
if getline('.') !~ '^\s*\&#35;'
 
 
if g:web_browser == "konqueror"
 
 
exe ":!dcop `dcopfind -a 'konqueror*'` konqueror-mainwindow\\&#35;1 newTab ".getline('.')
 
 
elseif g:web_browser == "mozilla"
 
 
exe ":!mozilla -remote \"openurl(".getline('.').", new-tab)\""
 
 
endif
 
 
endif
 
 
endfunction
 
 
 
 
Note: you can select in Visual mode few lines and open in one keypress
 
 
few tabs. Comment lines with &#35; at the beginning. This lines won't be
 
 
precessed with function.
 
 
 
 
I am sure such operation are possible also with other webbrowsers with
 
 
tabs.
 
 
 
 
Konqueror from KDE3.2-Alpha1 (but this dcop commands should work also
 
 
with older versions)
 
 
Mozilla 1.4
 
 
 
}}
 
 
== Comments ==
 
<!-- parsed by vimtips.py in 0.696004 seconds-->
 

Revision as of 07:26, 4 November 2007

Tip 555 Printable Monobook Previous Next

created September 11, 2003 · complexity intermediate · author Mikolaj Machowski · version 6.0


Sometimes you are collecting bookmarks from various sources, not only web, mail client, usenet even newspapers. Sometimes it is not possible or convenient to insert them in your favorite web browser bookmark manager. But nothing is lost - you can use Vim.

Keep all URLs in one file called, for example, url – one URL per line.

Put this in your .vimrc:

autocmd BufRead ~/url map <F8> :call BrowserURL()<cr>
let g:web_browser = "konqueror"
function! BrowserURL()
  if getline('.') !~ '^\s*\#'
    if g:web_browser == "konqueror"
      exe ":!dcop `dcopfind -a 'konqueror*'` konqueror-mainwindow\\#1 newTab ".getline('.')
    elseif g:web_browser == "mozilla"
      exe ":!mozilla -remote \"openurl(".getline('.').", new-tab)\""
    endif
  endif
endfunction

Use visual mode to select one or more lines, then press a key to open the URLs in tabs. Any line starting with '#' is a comment and is skipped.

I am sure such operation are possible also with other web browsers with tabs.

Konqueror from KDE3.2-Alpha1 (but this dcop commands should work also with older versions)

Mozilla 1.4

Comments