How can I Insert the result of a ".w" evaluation at the end of a line in Vim?

diplomaticDeveloper

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>) 을 만드는 것입니다.

Horst

라인이 다음과 같은 경우 : 4 + 5 = 다음과 같이 사용할 수 있습니다.

 : 맵 "_ay / = ^ Mo ^ [!! echo ^ Ra \ | bc ^ MkJ
  1. _ ............... to jump to start of actual line
  2. "ay/=^M ... to yank till = into buffer a
  3. o^[ ........... make a new empty line
  4. !! .............. start a shell program to write result into this new line
  5. ^Ra .......... insert content of buffer a in comand: echo ^Ra \| bc^M
  6. k .............. go to pevious line
  7. J .............. join next line (result) to aktual line
  8. perhaps you want to delete blank from joining with x

I hope this is what you are .

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How can I apply padding to the end of a line?

분류에서Dev

How can I copy/paste pattern the current line in vim

분류에서Dev

Vim : How to actually insert line numbers in the file?

분류에서Dev

Can I configure Vim to go to the end of particular file?

분류에서Dev

How to insert the date into vim

분류에서Dev

How can I multiple insert the data in rails

분류에서Dev

How can i insert current date in robomongo?

분류에서Dev

Vim, how to delete from CURRENT cursor position, until end of line and next N lines?

분류에서Dev

How can I compare two files line by line?

분류에서Dev

How can I compare two files line by line?

분류에서Dev

How can I emulate key presses on Vim startup?

분류에서Dev

How can I determine a variable's type in a vim function?

분류에서Dev

How can I use vim to view git diffs on Windows?

분류에서Dev

How can I create my own spelling file for vim?

분류에서Dev

How can I get a block cursor in Vim in the Cygwin terminal?

분류에서Dev

How can I discard my undo history in vim?

분류에서Dev

How can I get vim autocompletion working in iTerm

분류에서Dev

How do I insert a line at the top of a text file using the command line?

분류에서Dev

How can I stretch (not tile) an UIImage with end caps

분류에서Dev

How can i have a multiselect option in right side end

분류에서Dev

How can i upload image from front-end in magento?

분류에서Dev

How can I concatenate to the end of a route using Laravel?

분류에서Dev

How can I change the number of items that end up in a list

분류에서Dev

How can I get the result in the UI (@escaping , completion)

분류에서Dev

How can I intercept the result of openDocument before NSDocument loads?

분류에서Dev

How can I print the result of add function..?

분류에서Dev

How can I choose a function at compile time based on a constexpr result

분류에서Dev

How can I choose a function at compile time based on a constexpr result

분류에서Dev

sqlalchemy - how can I get update method result?

Related 관련 기사

  1. 1

    How can I apply padding to the end of a line?

  2. 2

    How can I copy/paste pattern the current line in vim

  3. 3

    Vim : How to actually insert line numbers in the file?

  4. 4

    Can I configure Vim to go to the end of particular file?

  5. 5

    How to insert the date into vim

  6. 6

    How can I multiple insert the data in rails

  7. 7

    How can i insert current date in robomongo?

  8. 8

    Vim, how to delete from CURRENT cursor position, until end of line and next N lines?

  9. 9

    How can I compare two files line by line?

  10. 10

    How can I compare two files line by line?

  11. 11

    How can I emulate key presses on Vim startup?

  12. 12

    How can I determine a variable's type in a vim function?

  13. 13

    How can I use vim to view git diffs on Windows?

  14. 14

    How can I create my own spelling file for vim?

  15. 15

    How can I get a block cursor in Vim in the Cygwin terminal?

  16. 16

    How can I discard my undo history in vim?

  17. 17

    How can I get vim autocompletion working in iTerm

  18. 18

    How do I insert a line at the top of a text file using the command line?

  19. 19

    How can I stretch (not tile) an UIImage with end caps

  20. 20

    How can i have a multiselect option in right side end

  21. 21

    How can i upload image from front-end in magento?

  22. 22

    How can I concatenate to the end of a route using Laravel?

  23. 23

    How can I change the number of items that end up in a list

  24. 24

    How can I get the result in the UI (@escaping , completion)

  25. 25

    How can I intercept the result of openDocument before NSDocument loads?

  26. 26

    How can I print the result of add function..?

  27. 27

    How can I choose a function at compile time based on a constexpr result

  28. 28

    How can I choose a function at compile time based on a constexpr result

  29. 29

    sqlalchemy - how can I get update method result?

뜨겁다태그

보관