Loading ...
Sorry, an error occurred while loading the content.

20846RE: decapitlising on the fly

Expand Messages
  • Ash Searle
    Sep 7 9:12 AM
    • 0 Attachment
      Thought I should share this slightly improved version. I don't
      know how often anyone types "i.e.", or if there are any other
      latin things like that, but, I don't believe it should be
      capitalized.

      Oh, mapping to <Space> doesn't help when you make a typo in the
      last word of a line (before pressing return.) So, you need to
      map <CR> too.

      function! Decap()
      let l:line = getline(".")
      " decapitalize words (e.g. THat -> that)
      let l:line = substitute(l:line, '\<\(\u\)\(\u\)\([^A-Z \t.]\)',
      '\1\L\2\e\3', 'g')
      " turn i's into I's (but not in i.e.'s)
      let l:line = substitute(l:line, '\<i\>\(\.e\.\)\@!\|\<i$', 'I', 'g')
      call setline(".", l:line)
      endfunction

      ino <Space> <Space><C-O>:call Decap()<CR>
      ino <CR> <C-O>:call Decap()<CR><CR>

      > -----Original Message-----
      > From: Mark Zealey [mailto:mark@...]
      > Sent: 3 September 2001 21:45
      > To: vim@...
      > Subject: Re: decapitlising on the fly
      >
      >
      > > function! Decap()
      > > let l:line = getline(".")
      > > " decapitalize words (e.g. THat -> That)
      > > let l:line = substitute(l:line, "\\<\\(\\u\\)\\(\\u\\)\\([^A-Z
      > > \\t.]\\)", "\\1\\L\\2\\e\\3", "g")
      > > " turn i's into I's
      > > let l:line = substitute(l:line, "\\<i\\>", "I", "g")
      > > call setline(".", l:line)
      > > endfunction
      > >
      > > inoremap <Space> <C-O>:call Decap()<CR><Space>
      >
      > This is nice, maybe use ''s rather than "'s to avoid the need for
      > lots of \'s...
      >
      > --
      >
      > Mark Zealey (aka JALH on irc.openprojects.net: #zealos and many more)
      > mark@...
      >
      > UL++++>$ G!>(GCM/GCS/GS/GM) dpu? s:-@ a16! C++++>$ P++++>+++++$
      > L+++>+++++$
      > !E---? W+++>$ N- !o? !w--- O? !M? !V? !PS !PE--@ PGP+? r++ !t---?@ !X---?
      > !R- b+ !tv b+ DI+ D+? G+++ e>+++++ !h++* r!-- y--
      >
      > (www.geekcode.com)
    • Show all 6 messages in this topic