Equivalent scrapbook

…scrap on Vim

vim substitude

rename class name to method name

StaticDocumentForm
:s/[A-Z]/_\l\0/g
_static_document_form

I'm to lazy to figure out the leading underscore :)

multiply string in vim

just in visual mode highlite string row, pres '/' and type

s/mystring/&&

mystirng

:'<,'>s/mystring/&&'  # vim command line

mystirngmystirng

more

&
sings you use more duplication you get

:'<,'>s/mystring/&&&&&&&&'  # vim command line

mystringmystringmystringmystringmystringmystringmystringmystringmystring

Charset problem with vim and ruby

if you ever have this problem

 invalid multibyte char (US-ASCII)

just in vim do

set bomb

and save file

http://stackoverflow.com/questions/5809412/global-settings-to-solve-invalid-multibyte-char-us-ascii-in-rails-3

Ctags

install ctags from bash or upgrade it (under ubuntu synaptic is pretty old)

apt-get install ctags

add tags to .gitignore list

ctags -R --exclude=log * --exclude=.git *

screencast source

Bonus

add alias to your ~/.bashrc (delate old tags, regenerate new tags)

alias ctagrails='rm -R ./tags; ctags -R --exclude=log * --exclude=.git *'??

keywords: ctags c tags navigation jump

h3. Adding and removing quotes with vim combos

As you know vim have build-in text editing combos like @di'@ witch will delete text inside @''@, for example: ??"text" di" will resoult to ""??. I wanted to be able to add/delete quotes braced on word like ??"text" somecombo will resoult to text??. Vim build-in solution doesn't exist, so I had to put into my @.vimrc@ file solution, googled by my college, founded "here":http://vim.wikia.com/wiki/Simple_Macros_to_quote_and_unquote_a_word

??" 'quote' a word
nnoremap qw :silent! normal mpea'bi'

pl
" double "quote" a word
nnoremap qv :silent! normal mpea"<Esc>bi"<Esc>
pl
" remove quotes from a word
nnoremap ciq :silent! normal mpeld bhd `ph??

Now I have combos
??word qw "word"
word qv 'word'
"word" ciq word??

h3. How to join middle mouse button clipboard with vim yank/paste

??set clipboard=unnamed??
now when you select text with mouse, it will be avalible in vim paste (hit p) or other way when you yank text in vim (yy) you can paste it with middle mouse button anywher in your system (in browser for example)

h3. C tags on vim

"source":http://www.faqs.org/docs/ldev/0130091154_64.htm

To turn any indent modes on, with the application in Normal mode, type
:set
. To turn off an indent mode, simply preface the mode name with the word

no
”. For example, to turn on
??cindent??
, type:
??:set cindent??
To turncindent back off, type:
@:set nocindent@