Wednesday 24 April 2013

Vim

I have been using Linux for a number of years now and right from the start have been using Vim.
It is an elite text editor with a number of inside jokes about it.   Love it or hate it, a skilled Vim operator will out perform any peers on other text editors.   I am not excluding Vi comparable text editors here.

That being said, I am not an expert and this blog post is a repository of commands I am learning and have learned.   I plan on using this page to remind myself of the rarely used commands.   This page will be updated often.

So hear are the commands I am learning or know so far;

%s/foo/bar/g     [Find and Replace foo with bar]
V then =         [Reformat Selection]
n      [After Search Find Next]
v      [Visual Mode]
V      [Visual Mode Line Select]
gg=G   [Re-indent Entire Document]
p      [Put or Paste Buffer]
y      [Yank or Copy Selected]
dd     [Delete the Current Line]
3dd    [Delete Three Lines]
u      [Undo]

Just for reference, here is my vimrc config file;

" Debian Statement
runtime! debian.vim

" Set Syntax and FileType
syntax on
filetype on
filetype indent on
filetype plugin on

" Set Omni completion filetype associations
set ofu=syntaxcomplete#Complete
autocmd FileType html :set omnifunc=htmlcomplete#CompleteTags
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete


" Set Search Format
set incsearch
set ignorecase
set smartcase

" Set Tab Style
set expandtab
set shiftwidth=2
set tabstop=2
set softtabstop=2
set smartindent
set autoindent
set wildmode=longest:full
set wildmenu

" Set Visual Style
set cursorline
hi CursorLine term=none cterm=none ctermbg=3

" Key Maps - Insert Mode
imap ii <C-[>

" Set Environment Values
set nocompatible
set showcmd
set showmatch
set ignorecase
set smartcase
set incsearch
set autowrite
set hidden
set viminfo='100,<100,s10,h

" Enable Terminal Colour Support
if &term =~ "xterm"
set t_Co=256
if has("terminfo")
   let &t_Sf=nr2char(27).'[3%p1%dm'
   let &t_Sb=nr2char(27).'[4%p1%dm'
else
   let &t_Sf=nr2char(27).'[3%dm'
   let &t_Sb=nr2char(27).'[4%dm'
endif
endif



No comments:

Post a Comment