What is the easiest way to swap occurrences of two strings in Vim?

I’d do it like this: :%s/\v(foo|bar)/\={‘foo’:’bar’,’bar’:’foo’}[submatch(0)]/g But that’s too much typing, so I’d do this: function! Mirror(dict) for [key, value] in items(a:dict) let a:dict[value] = key endfor return a:dict endfunction function! S(number) return submatch(a:number) endfunction :%s/\v(foo|bar)/\=Mirror({‘foo’:’bar’})[S(0)]/g But that still requires typing foo and bar twice, so I’d do something like this: function! SwapWords(dict, …) let … Read more

Vim key bindings in Xcode?

If you still interested in Vim keybinding plugin for Xcode I made one. Here it is. http://programming.jugglershu.net/softwares/xvim.html This is currently developed for personal (my) use. So you may feel bad with some lack of implementation. Give me a feed back(feature request) then. I’ll add some keybinds if I have enough time.

Setting a VIM bookmark

If you type ma , it will create bookmark on the current line at the current location with name a. for example, typing ma has created a bookmark at the exact location where the cursor is highlighted To Access Bookmarked Line Inside Vi you can use – {macro-name} backtick followed by the macro name. Move … Read more

Quickest Way to Revert Spaces to TABs in VIM

VIM will automatically enable the TAB for a makefile, assuming you name it “makefile,” as opposed to “Makefile.” Not sure why VIM still doesn’t detect the type with a lower-uppercase difference, but such is life. (@Sedrik) That aside, other alternative solutions are: Filetype Binding (@ThorstenS @tungd): autocmd FileType make setlocal noexpandtab RealTime Switch (@ThorstenS): Assuming … Read more

Cannot create backup file(add ! to overwrite)

You can, as vi (or, more likely, vim) is saying force a write by doing: :w! Alternatively, write the file to an alternative location: :w! /path/to/other/location To check where your backup files are being written (normally): :se backup? backupdir? backupext? Try to touch a file in that directory and see if your Operating System gives … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)