m (Fixed formatting) |
(Change to TipImported template + severe manual clean) |
||
Line 1: | Line 1: | ||
{{review}} |
{{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=872 |
|id=872 |
||
+ | |previous=871 |
||
− | |title=Finding phone numbers |
||
+ | |next=873 |
||
− | |created=February 10, 2005 |
+ | |created=February 10, 2005 |
|complexity=intermediate |
|complexity=intermediate |
||
|author=Bertram Scharpf |
|author=Bertram Scharpf |
||
|version=6.0 |
|version=6.0 |
||
|rating=3/6 |
|rating=3/6 |
||
⚫ | |||
− | |text= |
||
− | I have a little script making |
+ | 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: |
<pre> |
<pre> |
||
− | func CPhone( ...) |
+ | 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 |
||
− | endif |
||
− | + | return nr |
|
− | endf |
+ | endf |
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
</pre> |
</pre> |
||
⚫ | |||
− | == |
+ | ==Comments== |
− | This makes no sense? Does |
+ | This makes no sense? Does Vim dial the number? |
− | Mohanjit Singh Malik |
||
− | , February 15, 2005 15:13 |
||
---- |
---- |
||
− | My shell script |
+ | My shell script 'dial' does that. I omitted it because writing "ATDT" sequences to '/dev/ttysS0' has nothing to do with Vim. |
− | |||
⚫ | |||
⚫ | |||
− | Bertram Scharpf |
||
− | , February 16, 2005 1:32 |
||
---- |
---- |
||
− | <!-- parsed by vimtips.py in 0.448448 seconds--> |
Revision as of 10:05, 1 December 2007
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.