我的系统:xp + gvim.
我打开gvim来编辑一个javascript语句,该文件还没有名字.
print(sum(range(1, 10)));
Run Code Online (Sandbox Code Playgroud)
我想映射<F7>
到javascript,我怎么能写出地图句子_vimrc
? 当配置完成后 我
如何55
输入F7
?
我elclanrs
这么说,错误输出是
C:\WINDOWS\system32\cmd.exe /c ( node ^<C:\DOCUME~1\sanya\LOCALS~1\Temp\VIi8C.tmp)
[stdin]:1
print(sum(range(1, 10)));
^
ReferenceError: range is not defined
at [stdin]:1:11
at Object.<anonymous> ([stdin]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at ReadStream.<anonymous> (node.js:154:11)
at ReadStream.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
shell returned 8
Hit any key to close this window...
Run Code Online (Sandbox Code Playgroud)
在VIM中运行JavaScript的最简单方法是安装NodeJS,然后使用VIM在Node中运行当前缓冲区
:w !node
Run Code Online (Sandbox Code Playgroud)
你甚至不需要保存它.用途console.log
:
console.log(sum(range(1, 10)));
Run Code Online (Sandbox Code Playgroud)
映射F7.适用于当前文件:
map <F7> :call Run() <cr>
function Run()
exec "! node %"
endfunction
Run Code Online (Sandbox Code Playgroud)
要在浏览器中执行它,您只需将其编写为HTML格式的脚本:
<script>
alert('in browser!');
</script>
Run Code Online (Sandbox Code Playgroud)
并在浏览器中运行它,例如F5:
map <F5> <Esc>:silent !google-chrome %<cr>
Run Code Online (Sandbox Code Playgroud)