Linked Questions

0 votes
2 answers
185 views

How do you use a variable as argument to another vim command? [duplicate]

I have the following function: fu! EditFileInBrowser() let l:url = @+ let l:url = substitute(l:url, 'http:\/\/127\.0\.0\.1:4000\/', '', '') let l:url = substitute(l:url, '/$', '', 'g') let l:...
StevieD's user avatar
  • 1,417
1 vote
1 answer
99 views

Use variable in vim mapping async task [duplicate]

I am trying to use a variable in this mapping: let board_ip = "192.168.100.18" │ nnoremap <F6> :AsyncRun echo . ...
Chris's user avatar
  • 141
0 votes
0 answers
23 views

how to reference variables in config [duplicate]

Let's take undodir as an example; we might have something like this in our vimrc: set undodir=$HOME/.config/nvim/undo/ In order to make config platform-agnostic one might want to use variables ...
laur's user avatar
  • 159
1 vote
0 answers
18 views

Return value to custom function [duplicate]

I'm writting a function to integrates NERDTree with Ack. The goal is to create a "Find in Directory". I create this: function! Fif_NERDTreeGetPath() let nodePath = g:NERDTreeFileNode.GetSelected()....
Diego Somar's user avatar
0 votes
0 answers
13 views

autocommand variable is not substituded [duplicate]

let Dropbox = "/usr/Dropbox" ... autocmd BufNewFile *.php 0r Dropbox/vim/templates/php_start.txt The variable 'Dropbox' is not substituded by its value
lima2018's user avatar
24 votes
3 answers
15k views

How to use a variable in the expression of a 'normal' command?

How can one use a variable when executing something via normal! in vimscript? Example: function! MyFunction(someArg) normal! (a:someArg)l endfunction This should move the cursor someArg steps ...
user avatar
0 votes
1 answer
3k views

how to use variables in vimscript shell commands

I have this code intended to: read current line extract variable from end of line, looking for text like #ad04e482 search for filename that begins with the string ad04e482 open that file to edit in ...
alec's user avatar
  • 785
2 votes
2 answers
668 views

Insert output of function with variable into buffer

I'm trying to make a vim function that takes a variable and uses that as part of a shell command and buts it into the current buffer. I tried using read but that just interprets the var as a string. ...
hemlock's user avatar
  • 23
0 votes
2 answers
929 views

Can I use a variable in autocmd pat?

I have 3 languages and any can be a source or target so I need some flexibility. I am successfully loading a language translation specific setup with this: let g:tr_source = 'dyu' let g:tr_target =...
Boyd's user avatar
  • 199
0 votes
1 answer
275 views

Use normal command output as variable

I want to be able to use some normal commands I tend to use in the day to day as an input for another function, for example 4X, I would like 4X to be expanded to XXXX and then use it in a function as :...
Hassek's user avatar
  • 103
1 vote
2 answers
571 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 ...
Riley Hughes's user avatar
1 vote
3 answers
244 views

How can I set path of vim from the shell command result

I'd like to set c++ header file path automatically from .vimrc. So I tried to write .vimrc file as shown below: let g:gcpp_headers_path=system("g++ --version | grep g++ | awk '{print \"/usr/...
Jumogehn's user avatar
  • 121
1 vote
1 answer
505 views

Custom key binding for project-wide search and replace using FZF.vim Rg function?

I know that one can do a project-wide search and replace using the results of an Rg search in FZF.vim by doing the following: Run :Rg SEARCH_TERM Use Alt + a (or in my case, Esc + a, since I'm using ...
rplee's user avatar
  • 177
1 vote
2 answers
259 views

switch current directory between a base directory and current file directory

Goal: To achieve filename/path completion relative to current file directory using file name completion CTRL-X CTRL-F. I open all my files contained in a base directory such that :pwd in some_file ...
Haslo Vardos's user avatar
1 vote
1 answer
314 views

How can I use a variable line number with a command?

I want to move a line to another specified in a variable. So where I might do this to move the current line up seven lines: :m-7 I want to do it with a variable line destination. Something like this: ...
markling's user avatar
  • 319

15 30 50 per page