Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8424729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:04:55+00:00 2026-06-10T04:04:55+00:00

Here I got simple task for skilled vimmers. I need to reformat my css

  • 0

Here I got simple task for skilled vimmers. I need to reformat my css file. There are commands to do this:

%s/}/&\r/g
%s/  /   /g
retab!
echo "You done did it!"

But I don’t want to type these commands every time I need to format my css file (I get it after convert less file by WinLess program). Now I put these commands into cssformat.vim file, and put this file into vim runtime folder. In my vimrc I set:

autocmd Filetype css nmap :so $VIM/vim73/cssformat.vim

It’s works, of course. But I wonder how can I do this task better? In the begginig I want to put these commands in my vimrc (to create a simple function), but I don’t know how to do this correctly.

p.s. Sorry for my bad English.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:04:57+00:00Added an answer on June 10, 2026 at 4:04 am

    Just put the commands from your script into a function:

    function! ReformatCss()
        " Place your commands here.
    endfunction
    

    And move the stuff into your .vimrc. Now you can invoke this via :call ReformatCss().

    To top it off and make it even simpler, define your own command:

    command! ReformatCss call ReformatCss()
    

    Now you can invoke via :ReformatCss. Voila!


    You can learn more at :help usr_40.txt and :help :command. For example, if you only need this for CSS files, you can turn this into a buffer-local command through command -buffer and moving the function and command definition to ~/.vim/ftplugin/css_reformat.vim

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i've got here a simple program, but it's not working properly. When i
Got a simple Javascript program here to accept and check a password. It should:
I think I have got something simple wrong here. I am trying to pass
I've got a quite strange problem here. I'm calling some simple code via Ajax.Updater:
I'll make it simple, here's the code I've got. public ActionResult DeleteNonCIStaffUser(int id) {
I am having a trouble with this simple task for last couple of hours.
So here's the scenario. I've got a script that runs some tests. I need
I got a simple question here, but it is confusing me a lot.. Can
Here's what I have done: I've got a simple class: class Person{ public: Person();
I've got a simple menubar, seen here . My issue is that when you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.