[英]How do I write an image to buffer using native Node JS HTTP library?
[英]Using Vim as a Javascript Sandbox: How do I write a buffer to node and read the result in another buffer?
我正在嘗試將vim用作復雜的javascript沙箱編輯器。
最終目標是在左側窗口中包含我的代碼,並在右側窗口中動態更新node.js可執行文件的輸出。
我目前正在利用:
map <Leader>r :silent :w !node -p > /tmp/jsconsole<cr>
silent !cat '' > /tmp/jsconsole
botright vnew
e /tmp/jsconsole
set buftype=nofile
set bufhidden=hide
set nobuflisted
setlocal noswapfile
" set nomodifiable " maybe later once i can figure out how to lock/unlock
wincmd h
set buftype=nofile
set bufhidden=hide
set nobuflisted
setlocal noswapfile
autocmd QuitPre * :qa
set autoread
這行得通,有點。 我發現vim的自動autoread
功能不可靠。
理想情況下,我將能夠運行左側緩沖區的內容,而無需通過stdin通過node -p
保存文件,將stdout和stderr讀入右側緩沖區,這是不可編輯的。
我知道有幾種方法可以做到這一點,但是缺乏將它們粘合在一起的知識。
如何通過stdin將緩沖區內容傳遞給node -p
,捕獲stdout和stderr並將它們傳遞給其他緩沖區?
有各種各樣的腳本或多或少可以滿足您的需求。
我最近遇到了一個非常簡單的pipe2eval ,它可以讓您評估當前行或視覺選擇,並將結果插入下面的注釋中。
啞例子:
my_array = [1,2,3];
my_array.push(4);
my_array[3];
// 4
根據Randy的評論,將tmux頂部的vim-slime與tmux右側窗格中的節點REPL一起使用確實有效。 盡管我仍然對包含vim的答案感興趣,但這是一種非常有效地回答這個問題的有效方法。
盡管尚未設置,但我計划將其設置為由tmuxinator管理的特定tmux配置。
您可以使用https://github.com/metakirby5/codi.vim進行安裝,然后將其添加到您的.vimrc中
let g:codi#interpreters = {
\ 'javascript': {
\ 'rightalign': 0,
\ },
\ }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.