<p>Hey,</p>
<p>Simple question that I'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'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'm new, I'm just tinkering around and seeing how some things affect each other, so it's a bunch of "quick-runs" 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 ":w" 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'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 <leader>r :w<CR>:GoRun<CR></code></p>
<p>(Better practice might be to call the function directly)</p></pre>-Chase: <pre><p>I'll make a function like you suggested. Thank you! (Forgot to mention I'm new to vim as well, just trying all sorts of new things, haha).</p></pre>Azzk1kr: <pre><p>Here's what I usually do in my .vimrc:</p>
<pre><code>:map <C-b> :make!<CR>
</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 <F9> :!clear && ./myappbinary<CR>
: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 "go run", "go build" is for building to a binary, "go install" is for puting the binary in your bin folder, neither are required to run a go application with "go run".</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传