Sunday, March 23, 2014

Re: vim function for correct expansion in html and css

On Sunday, 23 March 2014 21:35:37 UTC+11, Sayth Renshaw wrote:
> I found this function online its not mine.(lines with # I have attempted to add to script)
> This function fixed correct expansion in html so for example
>
> <div>|</div> expands to
>
> <div>
> |
> </div>
>
> But in css it still incorrectly expands
>
> so this is the current default behaviour
> #myid {
> |}
>
> How can I get it to be?
>
> #myid {
> |
> }
>
> function! Expander()
> 64 let line = getline(".")
> 65 let col = col(".")
> 66 let first = line[col-2]
> 67 let second = line[col-1]
> 68 let third = line[col]
> 69
> 70 if first ==# ">"
> 71 if second ==# "<" && third ==# "/"
> 72 return "\<CR>\<C-o>==\<C-o>O"
> 73
> 74 else
> 75 return "\<CR>"
> 76
> 77 endif
> 78 # else if first ==# "{"
> 79 # if second ==# "}"
> 80 # return "\<CR>\<C-o>==\<C-o>O"
> 81
> 82 else
> 83 return "\<CR>"
> 84
> 85 endif
> 86
> 87 endfunction

I found the original post on stackoverflow. http://stackoverflow.com/a/18066591/461887

Still cannot get the correct cursor position in css though.

Sayth

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: