I have a bunch of sass files and my designer used the wrong syntax. I wanted :margin-top 1px
but he did margin-top: 1px
So I easily wrote a sub command:
:rubydo sub! /([\w-]+):/,':\1'
So that works and fixes all the colons and moves them in the place I want. I have about 50 sass files in a stylesheets
directory. How can I run this command on all my files in one shot? I'm not really sure how to go about this in vim
. Maybe something to do with grep
? I couldn't tell ya.
Using windows. Ctrl-W w to switch between open windows, and Ctrl-W h (or j or k or l ) to navigate through open windows. Ctrl-W c to close the current window, and Ctrl-W o to close all windows except the current one. Starting vim with a -o or -O flag opens each file in its own split.
Opening Multiple Files in VimYou can open multiple files at the start of the Vim editing session from the command line, or at any time from inside the Vim editing session.
Suppose you have opened a file on Vim editor and you want to split it vertically. To achieve this: Enter command mode by pressing the ESC button. Press the keyboard combination Ctrl + w , followed by the letter 'v' .
You can run commands in Vim by entering the command mode with : . Then you can execute external shell commands by pre-pending an exclamation mark ( ! ). For example, type :! ls , and Vim will run the shell's ls command from within Vim.
See this: http://vimdoc.sourceforge.net/htmldoc/editing.html#:argdo
I learned this command right now, but the help is clear.
Go for:
:args *.css :argdo %s/\([[:alpha:]-]\+\):/:\1/ge | update
Here is an example
:bufdo %s/oldStuff/newStuff/ge | update
just change your regex to fit your needs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With