- Why Would an Enemy Army Retreat if they Will Die Anyway
- What is the significance of number 3?
- Who is “Bharat Mata” & why is she having Indian tricolor flag?
- Find entries that use a specific block in their Matrix field?
- Importing data through feed-me plugin, crashing
- It's a long row ahead, boys
- This could be another Riley's Riddle
- A rhyming riddle made by me, is not as good as Riley's can be
- Come to me, I'll give you rest
- What research is this similar to — Deep CNN for generating images by classifying individual pixels — not a GAN
- how to save deep learning model and test it after training?
- Metric and Binary Variable in Cluster Analysis
- what is this round black rock contained in sandstone
- Does founding a company by E-residency (in Estonia) would create a conflict with my Blue Card in Germany?
- Connecting two ESP32/ESP8266 over internet
- Mega2560 master on RS485 bus stops communicating with VFD when I add another RS485 module
- rerun a char Concatenation
- Pointer memory allocation in function
- Run piece of code based on a feature
- self hostes Service for Software/Firmware distribution
Use Python to change to normal mode
I'm writing a function that uses Vim's Python API. The function runs while I'm in insert mode and I want this function to set my mode to normal mode.
I tried a few things, like for example, this
vim.eval(r'execute normal! \
But unfortunately this doesn't work. I just get the error VIM:E121: Undefined variable: execute. Any help would be greatly appreciated.
Also, generally speaking, I'd really like to know more about the vim module. It doesn't have a __file__ attribute, assuming that's because it's compiled. Is there source code anywhere I can view? Or generally where the file lives so that I can try importing it and running help(vim) without having to re-run my functions in a Vim environment. If you have any information on that, in particular, it'd help a lot. Thanks!
Your question is more of a vim issue than a python one. vim.eval is basically the same as vim's eval( which evaluates an expression and does not run a command like execute. A
Your question is more of a vim issue than a python one. vim.eval is basically the same as vim's eval( which evaluates an expression and does not run a command like execute. Additionally, your syntax for execute is wrong since the command takes a string: execute "normal! \
" would be more correct. You could instead use the expression form execute():
However, since you ultimately want to use a command I would recommend just using vim.command(cmd) instead. vim already has a command for leaving insert mode, stopinsert.
The documentation for the methods in the built-in vim module can be found using :help python which brings up doc/if_pyth.txt.2018-01-25 21:43:25