{"id":113,"date":"2013-06-03T21:17:35","date_gmt":"2013-06-03T21:17:35","guid":{"rendered":"http:\/\/www.notnull.ro\/log\/?p=113"},"modified":"2013-06-03T21:26:02","modified_gmt":"2013-06-03T21:26:02","slug":"vim-and-php-online-help","status":"publish","type":"post","link":"https:\/\/notnull.ro\/log\/vim-and-php-online-help\/","title":{"rendered":"Vim and PHP Online Help"},"content":{"rendered":"<p>Since  year 2000 I&#8217;m a big fun of vim editor, in that period I&#8217;ve switched from <a href=\"http:\/\/joe-editor.sourceforge.net\/\" >joe editor<\/a> to the more powerful <a href=\"http:\/\/www.vim.org\" >vim<\/a>.<\/p>\n<p>In that period I have used it mostly for PHP programming.<br \/>\nWhat was not quite OK was the fact that I did not have a PHP help &#8220;integrated&#8221; into my editor.<br \/>\nWhat I knew is that the documentation of C\/C++ was easy accessible within vim.<br \/>\nIn vim when editing C\/C++ code just go the the name of a function\/structure and press <strong>K (SHIFT + k)<\/strong> and magically you will notice the documentation of that word coming up.<br \/>\nThe background of this behaviour: when &#8220;K&#8221; is pressed the vim editor will run the command &#8220;man $word&#8221; and the output of this command is shown in your editor ($word is the word where the cursor is placed)<br \/>\nThe good thing is that the &#8220;K&#8221; bind key is configurable, all that we have to do is to run <strong>set keywordprg=\/path\/to\/my_script<\/strong> in vim (or put it in vim.rc file for needed extensions) and when the &#8220;K&#8221; key will be press then the vim will run &#8220;\/path\/to\/my_script $word&#8221;.<\/p>\n<p>The next good thing is that on PHP site if you need the documentation for a function or for a statement is enough to put in your browser an URL like http:\/\/www.php.net\/$a_word (e.g. <a href=\"http:\/\/www.php.net\/foreach\">http:\/\/www.php.net\/foreach<\/a> <a href=\"http:\/\/www.php.net\/printf\">http:\/\/www.php.net\/printf<\/a> ), and php.net will give you the documentation page.<\/p>\n<p>So, for PHP extension I&#8217;ve run <strong>set keywordprg=\/home\/mark\/my_php_doc<\/strong> and inside \/home\/mark\/my_php_doc I have next couple of lines:<\/p>\n<pre>\r\n#!\/usr\/bin\/bash\r\nelinks http:\/\/www.php.net\/$1\r\n<\/pre>\n<p>It will launch the elinks browser using URL http:\/\/www.php.net\/$1<br \/>\nNow I have an online PHP help available, always up to date \ud83d\ude09 .<\/p>\n<p>A lot of other things can be done here&#8230;<br \/>\nIf there is not internet available (hard to believe it nowdays) instead of visiting http:\/\/www.php.net\/site you can build your own script which will grep some local files and eventually will print the piece of file that you need to stdout (it will be redirected to your editor).<br \/>\nYou can also extend the documentation with the function\/classes from your own libraries, or for other languages than PHP you can search in the specific directories\/files .<\/p>\n<p>This is an old vim tip that I&#8217;m using since years, but few days ago talking with some other experienced vim users I&#8217;ve noticed that they were not aware of this feature of vim.<br \/>\nSo, I felt the need to share it with other people.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since year 2000 I&#8217;m a big fun of vim editor, in that period I&#8217;ve switched from joe editor to the more powerful vim. In that period I have used it mostly for PHP programming. What was not quite OK was the fact that I did not have a PHP help &#8220;integrated&#8221; into my editor. What <a href='https:\/\/notnull.ro\/log\/vim-and-php-online-help\/' class='excerpt-more'>&#8230; Read Full Article<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,29,5,18],"tags":[32,34,33,31,30],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-linux","category-php","category-programming","category-vim","tag-help","tag-keywordprg","tag-online","tag-php-2","tag-vim-2","category-8-id","category-29-id","category-5-id","category-18-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/posts\/113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":8,"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/posts\/113\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/posts\/113\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/media?parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/categories?post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notnull.ro\/log\/wp-json\/wp\/v2\/tags?post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}