Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Prompt to edit a corresponding .scss file when opening a .css file in vim
function! EditScss()
" The current file
let file = expand("%")
" The current file's basename plus .scss
let scss = expand("%:r") . ".scss"
" If the file exists
if filereadable(scss)
" Prompt the user and store the user's choice (1-indexed) in a variable
let choice = confirm("Do you want to edit " . scss . " instead?", "&Yes\n&No", 1, "Question")
" If the user picked [Y]es
if choice == 1
" Set file to the escaped scss filename
let file = fnameescape(scss)
endif
endif
" e[dit] the file
exe "e" file
" Execute the autocommands for the file
exe "doautocmd BufReadPost" file
endfunction
" Execute EditScss() whenever a *.css file is read
:au BufReadCmd *.css call EditScss()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.