7 votes
Accepted

Handling Complex Arguments in a Vim Command

You should be able to do this simply by splitting the arg on an = and going through a for loop. Something like the following should work. command! -nargs=+ MyCommand :call MyFunction(<f-args>) ...
Tumbler41's user avatar
  • 7,706
6 votes

Passing a # character to the shell in vimscript?

shellescape({string}[, {special}]) has an extra, optional argument {special} which exists exactly for this purpose. When the {special} argument is present and it's a non-zero Number or a non-empty ...
jamessan's user avatar
  • 10.9k
5 votes
Accepted

How to call the fzf Ag command with multiple arguments?

TL;DR: You can't pass ag options into that command. (But jump to the bottom for a different one.) Note the distinction between the :Ag command and the fzf#vim#ag function. The :Ag command calls the ...
Rich's user avatar
  • 31.3k
5 votes
Accepted

navigating multiple files - arguments and buffers

The only system I know of that comes with the real vi by default is Arch Linux. In all the others, the vi command is some kind of "alias" that points to a more advanced vi clone like nvi or vim. So ...
romainl's user avatar
  • 39.3k
5 votes

How does double star work in vim?

You can check with echo glob2regpat('tests/**/Helpers/**/*.php') to what regular expression this will be translated. This returns: ^tests[\/].*[\/]Helpers[\/].*[\/].*\.php$, so it will look only for a ...
Christian Brabandt's user avatar
4 votes
Accepted

Why argdo applies changes only to the last file?

When using :argdo Vim executes the command and then loads the next buffer. By default, it will therefore unload the current buffer before moving to the next buffer and if the current buffer is ...
Christian Brabandt's user avatar
4 votes
Accepted

Passing a # character to the shell in vimscript?

The problem is that some characters are considered special by the Vim commandline. In your case, # refers to the alternate file name. You can find the documentation with a full list at :help cmdline-...
Martin Tournoij's user avatar
4 votes
Accepted

How can i get the arglist count?

You can use the argv() function: $ vim a b c :echo argv() ['a', 'b', 'c'] There is also the argc() function to get the length of the argument list (which is the same as len(argv())). Note: I found ...
Martin Tournoij's user avatar
4 votes
Accepted

How to add files to argument list without adding them to buffer list?

:h args has the following lines: `If you give more than one file name when starting Vim, this list is remembered as the argument list. You can jump to each file in this list. Do not ...
alpha_989's user avatar
  • 881
4 votes

How to pre-process command line arguments provided to vim?

This doesn't answer your question, but it does answer your use-case. If you do :let &grepprg = "git grep --line-number" then running :grep <keyword> inside of vim will populate ...
Ari Sweedler's user avatar
4 votes
Accepted

Use cases of ":rewind"? How does it differ from ":b1"?

As I was told in the comments, the fundamental difference is that :b1 targets the buffer list and :rewind targets the argument list. :help buffer-list is a nice summary: args list buffer ...
Quasímodo's user avatar
  • 2,416
4 votes
Accepted

How to set read only for only one buffer

An alternate method is to modify your alias (I prefer functions, so I’ll show both): # alias alias vim='vim +"setlocal readonly" ascii' # function vim () { command vim +'setlocal readonly'...
D. Ben Knoble's user avatar
  • 25.4k
4 votes
Accepted

argdo vs bufdo for project-wide search and replace in specific folders

Meta This question is long (4 questions), and we normally prefer to keep questions to 1 question per question. The 4th is also opinion-based enough to be off-topic. However, the questions are related ...
D. Ben Knoble's user avatar
  • 25.4k
3 votes
Accepted

Navigate arglist via filename?

You can definitely navigate the argument list by filename with :argedit name but there are two problems with that command: one is is that :help :argedit is a rather low-level command, primarily meant ...
romainl's user avatar
  • 39.3k
3 votes
Accepted

argument list shows wrong current file

From :help arglist: If you give more than one file name when starting Vim, this list is remembered as the argument list. You can jump to each file in this list. Do not confuse this with the buffer ...
D. Ben Knoble's user avatar
  • 25.4k
3 votes
Accepted

how to use the number returned by arglistid()

Great question! The only existing use I can determine from the docs is that it allows you to find out whether a window is currently using a local arglist or the global one. However, it looks as ...
Rich's user avatar
  • 31.3k
3 votes

Use the arglist without opening the files

I would imagine, as D. Ben Knoble suggests, that if you don't anticipate a lot of interaction with the files, a different tool would be the way to go. find . -name \*.html -exec sed -i.bak 's/replace/...
jsharp's user avatar
  • 171
3 votes
Accepted

Can I run -c in batch mode (without opening the curses display)?

You can use the following, it is nearly what you have done (using another example to see difference), you need to add the hidden option: $ touch a b c $ cat * $ vi * +"set hidden" +"argdo r\!ls" +"...
nobe4's user avatar
  • 15.9k
3 votes
Accepted

Is is possible to change the order of the argument list?

$ touch {A,B,C,D,E,F}.md $ vim *.md :redir => current_args :silent args :redir END :let current_args = substitute(current_args, 'F', 'B', '') :let current_args = substitute(current_args, 'B', 'F',...
mMontu's user avatar
  • 6,600
2 votes
Accepted

Is it possible to add a file to the argument list with in netrw?

You can do the following: c make the current netrw directory the current vim directory :arge <C-r><C-f><CR> edit the file under the cursor Adding this line ...
romainl's user avatar
  • 39.3k
2 votes
Accepted

Plugin to edit whole datasets/projects

I use argdo in this answer, same rule applies to bufdo, windo , ... . Don't use argdo undo argdo undo failes in these conditions: Some buffers remain unchanged after last argdo, might caused by 0 ...
dedowsdi's user avatar
  • 6,188
2 votes
Accepted

Exiting back to normal mode in terminal buffer from Vimscript

:normal cannot be used while in terminal-mode (AKA "insert-mode in a terminal buffer"). Instead feedkeys() can be used (the second \ is not escaped--yet another Vimscript quirk): :call feedkeys("\<...
Justin M. Keyes's user avatar
2 votes

How to set read only for only one buffer

You will need to add to your vimrc an autocommand which will be executed every time you read the file and will be used to set the 'readonly' option on the file: augroup readonly autocmd! ...
statox's user avatar
  • 49.4k
2 votes
Accepted

How to pre-process command line arguments provided to vim?

I wonder if there is a way to automatically make this conversion so that in command line this statement: vim first/foo.py:123: would have the same result as this command: vim first/foo.py +123. There'...
filbranden's user avatar
  • 28.4k
2 votes
Accepted

List Vim arguments options

From :h vim-arguments: *info-message* The |--help| and |--version| arguments cause Vim to print a message and then exit. Normally the message is sent to stdout, thus can ...
ranemirusG's user avatar
2 votes
Accepted

How to force Vim to delete all the [No Name] buffers?

In the spirit of Friedrich's comment, using scratch buffers instead of regular buffers would seem to be a better strategy. FWIW, this is a very common use case for me, which I address with the ...
romainl's user avatar
  • 39.3k
1 vote

Disable E173: X more files to edit warning in neovim

With :set confirm, vim {a..c} then :quit gives me a prompt to quit (or not). Without :set confirm, the first :quit errors but the second (immediately afterwards) always succeeds.
D. Ben Knoble's user avatar
  • 25.4k
1 vote
Accepted

Disable E173: X more files to edit warning in neovim

You can do: :qa You can also run: silent bufdo normal! \<nop> It visits all the buffer and do nothing. After that action you can quit Vim with :q
Vivian De Smedt's user avatar
1 vote

Plugin to edit whole datasets/projects

I think building on your logic @dedowsdi one could then do argdo if &modified | earlier | endif I can see how one could have several wrapper functions written around this, that's great!
Jérémie Wenger's user avatar
1 vote

Handling Complex Arguments in a Vim Command

Merging back parameters like --foo="foo bar" requires manual work. Vim doesn't provide us anything to solve this issue. I remember having started an experiment on the subject. Unfortunately, this is ...
Luc Hermitte's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible