Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

Thursday, September 5, 2013

No syntax highlighting in vimdiff

Vim Syntax highlight often mixed with diff color, which makes text unreadable.

Add following line in ~/.vimrc to turn off syntax off in vimdiff

if &diff | syntax off | endif

Wednesday, March 6, 2013

Vim folding, auto fold xml, fold, unfold


To allow folds based on syntax add something like the following to your .vimrc:
set foldmethod=syntax
set foldlevelstart=1

let javaScript_fold=1         " JavaScript
let perl_fold=1               " Perl
let php_folding=1             " PHP
let r_syntax_folding=1        " R
let ruby_fold=1               " Ruby
let sh_fold_enabled=1         " sh
let vimsyn_folding='af'       " Vim script
let xml_syntax_folding=1      " XML

zo -- To open a fold block
zc -- To fold a block
zr -- Fold less
zm -- Fold more

Monday, June 25, 2012

VIM multiple clipboards(registers), without leaving insert model

To view your current registers type :reg. You'll notice that every register is prefixed with the symbol ".
How do you use these things? Let's say you want to copy a line into a specific register: "kyy will yank the current line into register "k. If you later want to paste register "k you can do this: "kp. 
If you want to put without leaving insert model:
ctrl-r follwed by the register lets you paste the contents of a register without leaving insert mode.
Ctrl + r" Put from the default register
Ctrl + rd Put from register d

Thursday, June 14, 2012

Enable spell checking in VIM

This is a feature of VIM I should know decades ago:

Enable spell checking:


:setlocal spell spelllang=en_us

  • ]s — move to the next mispelled word
  • [s — move to the previous mispelled word
  • zg — add a word to the dictionary
  • zug — undo the addition of a word to the dictionary
  • z= — view spelling suggestions for a mispelled word
Enable spell checking:

:set nospell

Monday, June 13, 2011

VIM increase number, increase alpha

Press Ctrl+A increase the number under cursor.

:set nrformats=alpha

can help you increase character.

Saturday, May 14, 2011

Wednesday, March 30, 2011

interactive shell in vim

:sh
exit
--
Ctrl-z
fg
--
Bang!
:! wc %
:! php5 -l %
:r textfile
:r ! ls -1 /home/user/directory
:r ! w3m http://en.wikipedia.org/wiki/Vi -dump