用Vim调用MSDN查询

找了一下, 暂时发现有两种方案.

一,

原文:http://vim.wikia.com/wiki/Context_sensitive_access_to_MSDN_help


created November 3, 2006 · complexity basic · author gosaca · version 6.0


Access MSDN help for a specific keyword from gvim on Windows.

Add following to gvimrc:

nmap <F1> :silent ! start iexplore "http://www.google.com/search?hl=en&btnI=I\%27m+Feeling+Lucky&q=site\%3Amsdn.microsoft.com\%20<cWORD>"<CR>

This accomplishes the following:

  • Starts a new instance of Internet Explorer.
  • Navigates to Google search.
  • Limits the search to site msdn.microsoft.com.
  • Searches for the term under the cursor.
  • Navigates the browser directly to the first page returned from the search.

For example, putting your cursor over WaitForSingleObject and hitting <F1> brings you directly to the documentation for that API on the MSDN site.

Use :set ch=2 to avoid the Hit Enter To Continue message.

The space between "!" and "start" is needed to avoid a "command not found" error. The space causes Vim to send the start command to the cmd.exe shell. Start is a cmd command, not a separate program.

CommentsEdit

Is there any reason that you don't search msdn directly? Something like:

nmap <F3> :silent !cmd /C start iexplore "http://search.msdn.microsoft.com/search/default.aspx?query=<cWORD>"<CR>;

The msdn search brings you to a search results page, from which you must click on another link to get the desired documentation.

Using Google's I'm Feeling Lucky feature navigates you directly to the first page returned by the search, which more often than not is the page you want (since you have limited your search to the msdn.microsoft.com site).

This closely replicates the function of context sensitive help via F1 when working in MSDEV.

In addition, you can always change the site: filter in the search query string to something other than msdn, if you aren't working on a win32 project.


用gvim 调browse到网上查询, 试了一下,效果很一般,,,,而且当网速不给力的时候就悲剧了,,不过实现就相对简单,



第二种

原址:

http://groups.google.com/group/vim-cn/tree/browse_frm/month/2008-06/7423d7f090bbe17e?rnum=31&_done=%2Fgroup%2Fvim-cn%2Fbrowse_frm%2Fmonth%2F2008-06%3F


主要程序为

/********callmsdn.c********** 
  by reaky 

  2012-02-09 hunter modify the format
 ******************************/ 
#include <windows.h> 
int main(int argc, char *argv[]) 
{ 
	MSG msg; 
	HWND hPaneWnd, hPaneLast, hCtlWnd; 
	HWND hwndHelp; 
	hwndHelp = FindWindow("HH Parent", "Microsoft Platform SDK, August 2001 Edition"); 
	while(!IsWindow(hwndHelp)) 
	{ 
		WinExec("D:\\MSDNLITE\\msdn.exe",SW_SHOW); 
		Sleep(2000); //wait for the startup of msdn 
		hwndHelp = FindWindow("HH Parent", "Microsoft Platform SDK, August 2001 Edition"); 
	} 
	ShowWindow(hwndHelp, SW_NORMAL); 
	SetForegroundWindow(hwndHelp); 
	//send ALT+N to the msdn window 
	PostMessage(hwndHelp, WM_SYSKEYDOWN,0x4E,1<<29); 
	hPaneWnd = FindWindowEx(hwndHelp, NULL, "HH Child", NULL); 
	for (;;) // last HH Child 
	{ 
		hPaneLast = FindWindowEx(hwndHelp, hPaneWnd, (LPCTSTR)("HH Child"), 
				NULL); // last HH Child 
		if (!hPaneLast) 
			break; 
		hPaneWnd = hPaneLast; 
	} 
	hCtlWnd = FindWindowEx(hPaneWnd, NULL, (LPCTSTR)("Button"), NULL); // skip Tab Control 
	if (hCtlWnd) 
	{ 
		hCtlWnd = FindWindowEx(hPaneWnd, NULL, (LPCTSTR)("Edit"), NULL); // skip Tab Control 
		// Set window text 
		SendMessage(hCtlWnd, WM_SETTEXT, 0, (LPARAM)argv[1]);     // fill it by our query 
		SendMessage(hwndHelp, WM_COMMAND, 0x00000bbe, 0); // 0x3f1 -- 'Display' button, it shows first item 
	} 
	else 
	{ 
		MessageBox(NULL,"MSDN not found!","ATTENTION",MB_OK); 
	} 
	return 0; 
} 




#if 0
/*callmsdn.c===>callmsdn.exe 
  cl /O1 /nologo callmsdn.c /link /subsystem:windows /entry:"mainCRTStartup" /align:32 /MACHINE:x86 /RELEASE user32.lib kernel32.lib 
//Add this into the _vimrc 
nmap <C-F1> :silent !start callmsdn <cword><cr> 
本人水平一般,望大牛改进。*/ 

#endif



上面这链接是一个思路,写一个程序,让VIM调用, 把需要查询的字符以参数形式传入这个自己写的程序中去. 

程序的思路就是找到当前的MSDN窗口,如未启动就启动它, 
把需要查询的字符传输入框之后,再发查询消息. 


我试了一下,还是没有实现...可能是我装的MSDN2001与文中所写不太一致吧... 



另外,介于本人是一个vim控, 如果最后能把MSDN的输出拦截,放到vim中去就好了.....


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值