Vim Tips Wiki
Register
(Adjust previous/next navigation)
(Remove html character entities)
Line 20: Line 20:
 
let nr=matchstr( getline("."), "\\s*\\zs".s."\\%".col(".")."c".s)
 
let nr=matchstr( getline("."), "\\s*\\zs".s."\\%".col(".")."c".s)
 
let nr=substitute( nr, "\\s\\+$", "", "")
 
let nr=substitute( nr, "\\s\\+$", "", "")
if nr == "" && a:0 && a:1
+
if nr == "" && a:0 && a:1
 
throw "No phone number under cursor."
 
throw "No phone number under cursor."
 
endif
 
endif
Line 26: Line 26:
 
endf
 
endf
   
let @p=":exec \":!dial '\".CPhone(1).\"'\"\<cr>"
+
let @p=":exec \":!dial '\".CPhone(1).\"'\"\<CR>"
   
 
augroup LocalUser
 
augroup LocalUser
autocmd BufRead phone* nnoremap &lt;buffer&gt; &lt;cr&gt; :exec ":!dial '".CPhone(1)."'"&lt;cr&gt;
+
autocmd BufRead phone* nnoremap <buffer> <CR> :exec ":!dial '".CPhone(1)."'"<CR>
 
augroup END
 
augroup END
 
</pre>
 
</pre>
Line 39: Line 39:
 
My shell script 'dial' does that. I omitted it because writing "ATDT" sequences to '/dev/ttysS0' has nothing to do with Vim.
 
My shell script 'dial' does that. I omitted it because writing "ATDT" sequences to '/dev/ttysS0' has nothing to do with Vim.
   
Roughly spoken, the script does an ":!echo -ne 'atdt,&lt;number&gt;;h0\r' &gt;/dev/ttyS0", having stripped off all non-digit characters before.
+
Roughly spoken, the script does an ":!echo -ne 'atdt,<number>;h0\r' >/dev/ttyS0", having stripped off all non-digit characters before.
   
 
----
 
----

Revision as of 09:35, 29 September 2008

Tip 872 Printable Monobook Previous Next

created February 10, 2005 · complexity intermediate · author Bertram Scharpf · version 6.0


I have a little script making my modem dial phone numbers. As the numbers are contained in a file I edit with Vim, I call the script with:

func CPhone( ...)
  " Get phone number under cursor
  let s="[-+./()0-9 ]*"
  let nr=matchstr( getline("."), "\\s*\\zs".s."\\%".col(".")."c".s)
  let nr=substitute( nr, "\\s\\+$", "", "")
  if nr == "" && a:0 && a:1
    throw "No phone number under cursor."
  endif
  return nr
endf

let @p=":exec \":!dial '\".CPhone(1).\"'\"\<CR>"

augroup LocalUser
  autocmd BufRead phone* nnoremap <buffer> <CR> :exec ":!dial '".CPhone(1)."'"<CR>
augroup END

Comments

This makes no sense? Does Vim dial the number?


My shell script 'dial' does that. I omitted it because writing "ATDT" sequences to '/dev/ttysS0' has nothing to do with Vim.

Roughly spoken, the script does an ":!echo -ne 'atdt,<number>;h0\r' >/dev/ttyS0", having stripped off all non-digit characters before.