王筝的博客
ruby学习

使用vim编辑器是能带来很大的便捷的,如何替换选中的多行中的某个单词呢。

先选中,按下冒号,左下方会出现 :'<, ‘>

在这个后面输入s/被替换单词/替换单词

如比   s/@subject/subject

后者会替换前者

 

 

 

查找:

Gsearch -F ‘aa’ -R  –include=*rb

 

替换:

(1)在查找结果中做 :%s/aa/bb/g

(2):Greplace 选择a

(3):wa


vundle安装方法如下

首先执行以下命令
$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

先在终端下执行 vim ~/.vimrc
如果存在.vimrc则打开,不存在.vimrc则创建一个.vimrc并打开。把下面的内容复制到 .vimrc中
filetype on
set langmenu=none
set fileencodings=utf-8
set fileencoding=utf-8
set encoding=utf8

set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set number
set autoindent
set hlsearch
set incsearch
set encoding=utf-8
" highlight Normal ctermfg=white ctermbg=cyan
set nowrap
syntax enable

let g:proj_window_width=5
set laststatus=2

map <C-T> :FufFile<CR>
map <C-E> :MRU<CR>
map <C-S-M> :Rmodel<CR>
map <C-S-C> :Rcontroller<CR>
map <C-S-U> :Runit<CR>
map <C-S-L> :Rfunctional<CR>
map <C-H> :Rhelper<CR>
map <C-V> :Rview<CR>
map <C-J> :ZoomWin<CR>

" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
    " Preparation: save last search, and cursor position.
    let _s=@/
    let l = line(".")
    let c = col(".")
    " Do the business:
    %s/\s\+$//e
    " Clean up: restore previous search history, and cursor position
    let @/=_s
    call cursor(l, c)
endfunction
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()

" match Todo /\s\+$/
filetype plugin on
let mapleader = ","

" THE VIM OUTLINER (TVO)
" defaults:
let otl_install_menu=1
let no_otl_maps=0
let no_otl_insert_maps=0

" overrides:
let otl_bold_headers=0
let otl_use_thlnk=0

" au BufWinLeave *.otl mkview
" au BufWinEnter *.otl silent loadview
let maplocalleader = ","

""Only do this part when compiled with support for autocommands.
"if has("autocmd")
"  autocmd Filetype java setlocal omnifunc=javacomplete#Complete
"endif

set nocompatible               " be iMproved
filetype off                   " required!

" ============== Vundle part =================
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'

" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
"Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'tpope/vim-rails.git'
Bundle 'tsaleh/vim-matchit.git'
Bundle 'ecomba/vim-ruby-refactoring.git'

" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
Bundle 'kchmck/vim-coffee-script.git'

Bundle 'git://git.wincent.com/command-t.git'
"Bundle 'snipMate'
"Bundle 'snipmate-snippets'
Bundle 'Jasmine-snippets-for-snipMate'
Bundle 'YankRing.vim'
Bundle 'vividchalk.vim'
Bundle 'The-NERD-Commenter'
Bundle 'The-NERD-tree'

colorscheme vividchalk
set background=light
set background=dark
Bundle 'mru.vim'
Bundle 'greplace.vim'

filetype plugin indent on     " required!
"
" Brief help
" :BundleList          - list configured bundles
" :BundleInstall(!)    - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!)      - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..

map <S-F> <Leader><Leader>f
map <Leader>a :YRShow<CR>
map <Leader>t :NERDTree<CR>
map <Leader>q :q<CR>
map <Leader>f :Rfixture<CR>
map <Leader>rj :Rjavascript<CR>

在终端输入 vim,  进入后输入 :BundleInstall 

安装完毕后  终端输入vim,按下 ctrl t,光标就自动跳转到上方,输入 **/ 就可以检索所有的文件了

发现了个非常赞的网站  http://openvim.com/

以下很多操作都是安装好vundle之后的操作哦

在命令行输入vim,进入vim,

输入 :NERDTree可以进入树形菜单

ctrl+t 光标会移动到顶端,输入**/abc   这样可以检索到所有名字中含有abc的文件

ctrl+ww 左右两侧的切换,左边是树形菜单,右边是代码,

ctrl+e 打开上一个打开过的文件

ctrl+n自动补全

shift+j 退行

shift+o 换行,另起一个新行

ctrl+c  快速切换到对应的controller

ctrl+v快速切换到对应的view

g;  跳到本文档上次编辑的地方

,a 显示曾经复制过的内容

shift+g 显示最后

shift+v选中后,按下=  可以调整格式,如对齐、缩进之类的

將光标移动到某个变量上,按gf可以打开,与此同时,ctrl+o可返回,ctrl+i可再次返回

:sp 切屏,水平方向上

:vs 垂直方向切屏

ctrl+f 上一页

ctrl+b 下一页

 

在操作的时候如果显示了you need to be root to perform this command,表示权限不足,在前面加sudo可以取得临时权限。

/字母  回车     (表示查找,n是从前往后,N是从后往前)

:%s/\$relea/17/g  替换$relea为17,看到g的时候很温馨,想到了js