0

I'm attempting to run the command "set tabstop=4" and then "retab" on multiple files.

I have gotten to point of getting my arglist like so

args ~/workspace/**/*.java

and I can see this work well when I'm just viewing the files using the args command. Now when I'm trying to run the "set tabstop=4" command on it, I'm just not able to get the correct combination of this. Ive tried

argdo "set tabstop=4" 

and then

argdo "update" 

but it never seems to apply the updates and I'm sure there are updates since I can go to one of the files individually and run the command and it changes the file. I've tried different combinations like

argdo execute "set tabstop=4"

and it just never seems to do anything. Any help would be appreciated!

Rahul
  • 391
  • 4
  • 17

1 Answers1

5

The syntax of :argdo (as per the :help) is

:argdo[!] {cmd}

No quoting is involved. To execute multiple commands in one go, just separate them with |:

:argdo set tabstop=4 | retab | update
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • So I tried doing this, and it does updates to the files - but for some reason when I view the file individually in vim (the indentation has been changed from the argdo command), it didn't have the same effect as just doing set tabstop=4 to the file i.e once I run that command and then after that, I go to a file individually and run "set tabstop=4" it is changed once again. – Rahul Nov 22 '14 at 19:36
  • The `:retab` command is tricky, you probably need to pass a number (`:retab 8`) to make it have any effect, maybe also add `!` when the original file uses spaces for indentation. Better find the right command on a single buffer, and only then apply via `:argdo`. – Ingo Karkat Nov 22 '14 at 19:40
  • So if I go to a file that I can is messed up with indentation, I just do a :set tabstop=4 and see everything fit into place, so I'm sure that command works perfectly per file, but now I've tried :argdo set tabstop=4 | update and its still just not the same effect (it seems to have added a much larger number for the tabstop) – Rahul Nov 22 '14 at 19:42
  • Actually I did a retab 8 as you suggested, I think I need to mess around with this as you said – Rahul Nov 22 '14 at 19:47
  • `:set tabstop=...` just changes the amount of space that Vim displays for a Tab character; it doesn't change the file itself! Only `:retab` does that! – Ingo Karkat Nov 22 '14 at 20:00
  • Ah I see. I was following - http://vim.wikia.com/wiki/Converting_tabs_to_spaces where it said "To change all the existing tab characters to match the current tab settings, use retab", so I was under the impression that it wasn't really required to change the file. Thanks! – Rahul Nov 22 '14 at 21:42