[Noob Question, DNU] Vim-Go -- Save, Build, Install, and Run Commands

polaris · · 733 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hey,</p> <p>Simple question that I&#39;m wasting too much time trying to figure out. Recently switched, new to the language (and compiled languages in general).</p> <p>After I make some tweaks to my program, to see it&#39;s results I have to:</p> <p>:w</p> <p>:GoBuild</p> <p>:GoInstall</p> <p>:GoRun</p> <p>Is there anyway to do all four of these commands in one go? Is there any command I can skip? It seems to take a long time to just test out a few small changes (since I&#39;m new, I&#39;m just tinkering around and seeing how some things affect each other, so it&#39;s a bunch of &#34;quick-runs&#34; of this http browser stuff)</p> <p>Also if there is a better way to do this, feedback would be appreciated. (I just figured this was the way to do it).</p> <hr/>**评论:**<br/><br/>icholy: <pre><p>Just :GoRun right away.</p></pre>-Chase: <pre><p>This works after saving manually &#34;:w&#34; otherwise it just runs what is unsaved. Any chance of incorporating save? This has still drastically improved the amount of time it took -- thank you!</p></pre>Fwippy: <pre><p>I&#39;d lean away from saving-and-running in one command, but if you want to create a mapping to do both, you can just throw something like this in your vimrc: <code>nnoremap &lt;leader&gt;r :w&lt;CR&gt;:GoRun&lt;CR&gt;</code></p> <p>(Better practice might be to call the function directly)</p></pre>-Chase: <pre><p>I&#39;ll make a function like you suggested. Thank you! (Forgot to mention I&#39;m new to vim as well, just trying all sorts of new things, haha).</p></pre>Azzk1kr: <pre><p>Here&#39;s what I usually do in my .vimrc:</p> <pre><code>:map &lt;C-b&gt; :make!&lt;CR&gt; </code></pre> <p>This maps <code>Ctrl+b</code> to run make in the current directory. If you use the <a href="http://github.com/fatih/vim-go" rel="nofollow">vim-go</a> plugin, this will run <code>go build</code> instead of the make program, IIRC. You can also combine commands like that. For instance I manually do this:</p> <pre><code>:map &lt;F9&gt; :!clear &amp;&amp; ./myappbinary&lt;CR&gt; :mksession! </code></pre> <p>This will clear my terminal, and run the compiled binary. Not sure if this is the best way, but it works for me. </p></pre>chreestopher2: <pre><p>if you just want to see the changes, just do &#34;go run&#34;, &#34;go build&#34; is for building to a binary, &#34;go install&#34; is for puting the binary in your bin folder, neither are required to run a go application with &#34;go run&#34;.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

733 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传