I'd like to be able to evaluate a line of Javascript (or other code) in Vim, and have the result appear in a comment at the end of the line.
For example, if I have a file like:
console.log(4 + 5);
and my cursor is on that line, and I use the command :.w !node -e
, the result "9
" will appear in the buffer below. if I use :. !node -e
, the whole line will be replaced with the result, 9
.
How can I instead create a command that will append the result to the line's end in a comment, like so:
console.log(4 + 5); // 9
또한 using :r
은 다음 줄에 전달되는 모든 내용을 인쇄합니다. 커서 아래 줄에 r !echo "This is text."
" This is text.
"를 삽입 합니다. 그러나 같은 명령은 ...
:r ". !node -e"
... ". !node -e"
명령 대신 파일 로 읽기 를 시도합니다 . 나는이 행동을 정말로 이해하지 못하지만, 그것은 일을 조금 덜 직관적으로 만든다.
최종 결과가 Atom 텍스트 편집기가 Hydrogen 커널을 처리하는 방식을 다소 연상시키고 코드 평가 결과가 코드 왼쪽에 표시되기를 바랍니다. 계획은 현재 줄을 자동 평가하고 결과를 표시 하는 키 바인딩 ( <C-Enter>
또는 <F5>
) 을 만드는 것입니다.
라인이 다음과 같은 경우 : 4 + 5 = 다음과 같이 사용할 수 있습니다.
: 맵 "_ay / = ^ Mo ^ [!! echo ^ Ra \ | bc ^ MkJ
I hope this is what you are .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다