[VIM] Delete a range of rows in vim

As time goes by, we can not waste the time to remove a thousand rows in vim line by line.

The solution is simple, for example we want to delete from line 2 to line 5 :

:2,5d
Advertisements

[VIM] active “Backspace” key in keyboard with .vimrc

My “Backspace” was not working ! What’s wrong !

You know it is expensive to change a keyboard when they are expire the guarantee period. My laptop was brought in 2006. 😦

I’m joking….

So if you want to active your “Backspace” key in VIM, what you have to do is insert this option in your .vimrc :

set backspace=indent, eol, start

Simple ? So we don’t have to pay for the keyboard 🙂

[VIM] Manage Vim plugin with Vundle in Ubuntu

I hope we already have a git 🙂 If not, find it here

To get vundle :

# git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

After installed, you have to configure your .vimrc in your home directory, if you have read my precedent blog, you have ignore the first part :

"###first part###
set nocompatible        "不使用vi默认键盘布局   (Not use default keyboard configue)
set number              "显示行号 (Show line number)
set autoindent          "自动对齐 
set smartindent         "智能对齐
set showmatch           "括号匹配模式
set ruler               "显示状态行
set incsearch           "查询时非常方便,如要查找book单词,当输入到/b时,会自动找到   第一个b开头的单词,当输入到/bo时,会自动找到第一个bo开头的单词,依次类推,进行查找时,使用此设置会快速找到答案,当你找要匹配的单词时,别忘记回车.
set tabstop=4           "tab键为4个空格
set shiftwidth=4       "换行时行间交错使用4个空格
set softtabstop=4      "设置(软)制表符宽度为4
set cindent             "C语言格式对齐
set nobackup            "不要备份文件
set clipboard+=unnamed  "与windows共享剪贴板

"###Second part###
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" Others
Bundle 'pangloss/vim-javascript'   "bundle for javascript
filetype plugin indent on    " required!

To install these bundle, you have to type the command in vim mode :

:BundleInstall

To reinstall :

:BundleInstall!

To clean (clear bundle) :

:BundleClean

PS. Sometimes you have to quit the file and re-enter to install.

[VIM] configure VIM with .vimrc in Ubuntu

In Ubuntu, to install VIM (if it is not installed by default)

sudo apt-get install vim

In my PC, there is no configuration file which is called .vimrc, what we have to do is just create it.

cd ~
vim .vimrc

The configuration (it will work automatically) :

set nocompatible        "不使用vi默认键盘布局   (Not use default keyboard configue)
set number              "显示行号 (Show line number)
set autoindent          "自动对齐 
set smartindent         "智能对齐
set showmatch           "括号匹配模式
set ruler               "显示状态行
set incsearch           "查询时非常方便,如要查找book单词,当输入到/b时,会自动找到   第一个b开头的单词,当输入到/bo时,会自动找到第一个bo开头的单词,依次类推,进行查找时,使用此设置会快速找到答案,当你找要匹配的单词时,别忘记回车.
set tabstop=4           "tab键为4个空格
set shiftwidth=4        "换行时行间交错使用4个空格
set softtabstop=4       "设置(软)制表符宽度为4
set cindent             "C语言格式对齐
set nobackup           	"不要备份文件
set clipboard+=unnamed  "与windows共享剪贴板

[VIM] Cheat sheet

VIM QUICK REFERENCE CARD

Basic movement
h l k j character left, right; line up, down
b w word/token left, right
ge e end of word/token left, right
{  } beginning of previous, next paragraph
( ) beginning of previous, next sentence
0 gm beginning, middle of line
^  $ first, last character of line
nngg line n, default the last, first
n% percentage n of the file (n must be provided)
n| column n of current line
% match of next brace, bracket, comment, #define
nnL line n from start, bottom of window
M middle line of window

Continue reading