Thursday, November 27, 2014

Re: vim keymap to execute bash script with parameter

huangyingw@gmail.com wrote:

> I want to implement such a feature in vim script: in command mode of
> vi, press v to select the key word, and then press F5, then vi call my
> bash file, called search.sh, passing the selected key word as
> parameter to the bash.

Is there a reason you are not using the <K> keystroke with the
keywordprg setting?

:help keywordprg

*'keywordprg'* *'kp'*
'keywordprg' 'kp' string (default "man" or "man -s", DOS: ":help",
OS/2: "view /", VMS: "help")
global or local to buffer |global-local|
{not in Vi}
Program to use for the |K| command. Environment variables are
expanded |:set_env|. ":help" may be used to access the Vim internal
help. (Note that previously setting the global option to the empty
value did this, which is now deprecated.)
When "man" is used, Vim will automatically translate a count for the
"K" command to a section number. Also for "man -s", in which case the
"-s" is removed when there is no count.
See |option-backslash| about including spaces and backslashes.
Example:
:set keywordprg=man\ -s
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.

I've installed the dictd server and dict client locally and use

set keywordprg=dict

Then typing K on a word gives me a definition.

[No write since last change]
3 definitions found

From The Collaborative International Dictionary of English v.0.48
[gcide]:

Definition \Def`i*ni"tion\, n. [L. definitio: cf. F.
d['e]finition.]
1. The act of defining; determination of the limits; as, a
telescope accurate in definition.
[1913 Webster]

[... verbose output, you'll be using your scroll bar to read ...]

Press ENTER or type command to continue

Elijah

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: