Questions tagged [execute]
The execute tag has no usage guidance.
19 questions
1
vote
2
answers
57
views
How can I test the result of execute saveas?
I have a function that renames a file by saving it to the new location then deleting the old:
execute "saveas" fnameescape(l:new_path)
call delete(l:old_path)
I ran into a problem with this ...
1
vote
1
answer
103
views
Why do these two nearly-identical bindings take different time to execute?
I like to open Vim with many buffers open, and switch between them using plugins. Because I work a lot in C++, I like to have a way to quickly switch between header files and their corresponding ...
0
votes
1
answer
50
views
Stream LLM tokens as are generated into Vim like via CLI mods or shell-gpt
Command line tools like mods or shell-gpt allow processing text with LLMs.
They can be used in Vim e.g.:
:3,12!mods -rqf 'Format as markdown bullet point list'
or:
:12,21!sgpt --code 'Implement TODOs ...
0
votes
0
answers
17
views
Make vim.execute function dot repeatable
I made the following keybinding to substitute "a/b" with "\frac{a}{b}".
-- convert / to \frac{}{}
-- (dot repeatable)
_G.div_to_latex = function()
vim.cmd('execute "normal f/...
0
votes
1
answer
33
views
Using the return of a user defined function in an :execute statement
I am trying to get the output of the following function to an :execute statement such as I have this in my .vimrc
def GetBufAbsPath(): string
return substitute(expand("%:p"), '[^\/]\+$', ...
2
votes
1
answer
795
views
Using the WSL terminal with Neovim
I have Neovim installed on Windows. I use WSL for running Python and C code. So I'd like to map a key to get Neovim to run a shell command in WSL directly from the Neovim editor. But I seem to be ...
0
votes
1
answer
100
views
How to run command using :norm?
Why does :norm :echo hi echo hi ? How can I do something like that?
I would like to :.,.+4norm :m5<cr>J
0
votes
1
answer
72
views
How do I use variables with the delete command? (i.e., how to expand/reference variables for command arguments?)
I'm using variables for line numbers, and I want to delete a range of lines using these variables. How do I do that?
let x = 5
let y = 20
" I want to delete the range of lines from x ...
2
votes
0
answers
69
views
How do I concatenate these strings? [closed]
I have two string variables:
let url = "https://URL/path/to/repo"
let branch = "GIT-HASH"
I want to concatentate them and echo it on the shell:
let result = url . branch
exec '!...
2
votes
1
answer
251
views
How can I have <C-E> and <C-Y>'s normal mode functionalities also work in insert mode?
Once I've asked a general question about special characters, but I've not really pulled anything out of it.
So now I'm asking a very specific question.
I want to have Ctrl+e and Ctrl+y behave in ...
2
votes
1
answer
212
views
How to :edit executable from path?
Environment: Linux
I apologize in advance if this question already exists somewhere and has a proper answer.
It is just so difficult for me to search because the keywords are all so generic.
Put ...
2
votes
1
answer
991
views
Special characters, escaped special characters, escape sequences, and terminal codes
I refer to those 4 terms using terminology picked up by various sources:
Steve Losh, in his Learn Vimscript the Hard Way's chapter 16 refers to things like <cr> (these 4 characters typed in a ...
0
votes
1
answer
48
views
Weird behavior when execute and echo are used together
So I was doing some testing on some function I made, let's call it Test_mode,
"let g:Test_mode = 0 " commented to show that it works without defining it first
function! Test_mode()
if g:...
3
votes
2
answers
938
views
How to `source` a path stored in a variable in Vimscript
tldr: The title pretty much summarizes the entirety of the question
I am trying to make my configuration more adaptable to different machines so that I can use git to keep them in sync between my ...
6
votes
2
answers
171
views
Advice on the use of :exe "norm!" vs. built in functions when writing vimscipt and plugins
I've been using vim for about 3 years and am starting to write my first
plugin. I've noticed when
looking at the code of other popular plugins that the functions very rarely
seem to achieve their aim ...
0
votes
0
answers
150
views
vim execute not working in script
I am using a plugin that expands the word template by a template but only if the word template is followed by a tab. I am trying to write the word new then in insert mode jump to the end of the line ...
2
votes
0
answers
68
views
Make Lightspeed work with Repmo
I'm trying to make the EasyMotion-like (cursor jumping) Lightspeed plugin work with Repmo which repeats a previous motion.
So far, (and after many hours), I've come up with the following:
let g:...
1
vote
1
answer
159
views
execute normal command does not work as expected
I have this line in the buffer:
* [X] determine how to add annotations #a475c217
I want to change it to this line:
* [X] determine how to add annotations ==ANN== #a475c217
So I run this command ...
0
votes
0
answers
125
views
Vim :redir + :execute prepends the executed command and blank lines to the output
I have the following function and command, which is supposed to save the output of a command to a scratch buffer:
function! ScratchCapture(cmd) abort
echo a:cmd
" Run and capture output in l:...