First time here? Check out the FAQ!

Ask Your Question
0

Running VIM inside Sage Shell

asked 6 years ago

o6p gravatar image

Is this possible? I want to work in Sage shell but I want to use VIM while typing up stuff in sage shell.

Preview: (hide)

Comments

Do you mean in the Sage shell, started by running sage -sh in the terminal, or in the Sage REPL (read-eval-print loop), started by running sage in the terminal?

slelievre gravatar imageslelievre ( 6 years ago )

2 Answers

Sort by » oldest newest most voted
2

answered 6 years ago

tmonteil gravatar image

You can use any bash command by starting with !, in you case:

sage: !vim my_file.txt
Preview: (hide)
link
2

answered 6 years ago

Iguananaut gravatar image

updated 6 years ago

You can also run

sage: %edit

which will open whatever you have $EDITOR set to first, and then fall back on vi otherwise.

The file is then saved to a temporary file and run when you exit, unless you do %edit -x (then it doesn't execute). While you're in your editor you can also write out to another file if you prefer.

Preview: (hide)
link

Comments

When I type %edit then 1+1 in vim (which is the editor of my system) and exit, it emits '1+1/n' which is not executed by SAGE. Any help?

pong gravatar imagepong ( 5 years ago )

same issue here

jin gravatar imagejin ( 4 years ago )

See the documentation for the %edit magic. It's a little confusing, but it does not work exactly the same as entering the code directly in the interactive prompt. If you just write a bare expression like 1 + 1, although it will be evaluated, its results are not displayed. Instead you have to write something like print(1 + 1) if you want the results displayed when executing the code. The %edit command outputs the code entered as a string allowing you to do things like %edit _ to re-edit the previous code.

Iguananaut gravatar imageIguananaut ( 4 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 6 years ago

Seen: 775 times

Last updated: Jul 13 '18