From ce013215d27caebff882240968c9b0e9a6d230e2 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Mon, 13 Dec 2010 13:15:43 -0500 Subject: [PATCH] Inline help in vim with vertical split. Added a small script to open a vertical split window with the output of cmake --help-command for the word under the cursor. --- Docs/cmake-help.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Docs/cmake-help.vim diff --git a/Docs/cmake-help.vim b/Docs/cmake-help.vim new file mode 100644 index 000000000..17cfa838e --- /dev/null +++ b/Docs/cmake-help.vim @@ -0,0 +1,21 @@ +nmap ,hc :call OpenCmakeHelp() + +function! OpenCmakeHelp() + let s = getline( '.' ) + let i = col( '.' ) - 1 + while i > 0 && strpart( s, i, 1 ) =~ '[A-Za-z0-9_]' + let i = i - 1 + endwhile + while i < col('$') && strpart( s, i, 1 ) !~ '[A-Za-z0-9_]' + let i = i + 1 + endwhile + let start = match( s, '[A-Za-z0-9_]\+', i ) + let end = matchend( s, '[A-Za-z0-9_]\+', i ) + let ident = strpart( s, start, end - start ) + execute "vertical new" + execute "%!cmake --help-command ".ident + set nomodified + set readonly +endfunction + +autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in nmap :call OpenCmakeHelp()