您的位置:首页 > 运维架构 > Linux

square开源vim,tmux配置在linux上使用

2013-11-24 20:04 267 查看
首先安装需要的软件

apt-get install vim ack-grep git tmux  gnome-terminal ctags xclip silversearcher-ag


这里tmux需要1.8版本,用tmux -V查看,如果不是可以下载自己编译。整个配置只能在gnome-terminal里面使用。

下载square开源配置

git clone git://github.com/square/maximum-awesome.git


因为配置文件是给mac os用的,linux下需要手动复制

cp -v tmux.conf ~/.tmux.conf
cp -v vimrc ~/.vimrc
cp -v vimrc.bundles ~/.vimrc.bundles
cp -v vimrc.bundles.local ~/.vimrc.bundles.local
cp -v vimrc.local ~/.vimrc.local


接着下载vundle自动管理插件

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


vundle自动安装插件

vim +BundleInstall +qall


gnome-terminal使用solarized配色


git clone git://github.com/sigurdga/gnome-terminal-colors-solarized.git
cd gnome-terminal-colors-solarized
./install.sh


根据提示选择完成配色

修改vim配置,使用solarized配色

vim ~/.vimrc.lcoal

找到colorscheme desert后,注释掉这行,下面添加
set background=dark "有dark和light两种可选
colorscheme solarized

修正gnome-terminal 下tmux颜色问题
echo "alias tmux=\"TERM=screen-256color-bce tmux\"" >> ~/.bashrc

终端启动时自动启动tmux

在~/.bashrc最后添加

if [[ ! $TERM =~ screen ]];then
TERM=screen-256color-bce tmux
fi

tmux下复制内容进粘贴板

修改~/.tmux.conf

找到 bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

这行,修改为

bind-key -t vi-copy y copy-pipe "xclip -i -sel p -f | xclip -i -sel c "

square配置的tmux使用方法
先按ctrl+a 进入命令模式后
: 命令行
L 清除历史
q 显示分割屏号
[ 进入复制模式
] 粘贴
v 复制模式中开始选择
y 拷贝选择
# 列出粘贴缓存
? 查看当前按键绑定
回车 重新布局

r 刷新当前窗口
空格 下一个窗口
退格 前一个窗口
c 新建窗口
t 下个窗口
T 上个窗口
1~9 选择窗口
! 分离当前分屏幕成新窗口
, 重命名窗口

h 选择左边分割屏
j 选择上边分割屏
k 选择下边分割屏
l 选择右边分割屏
v,% 垂直分割屏幕
s," 水平分割屏幕
ctrl+o 多个分割屏旋转
+ 使用垂直布局
= 使用水平布局
x,& 退出当前屏幕
alt+1~5 5种布局方式切换

ctrl+方向键 改变分屏幕大小1个单位
alt+方向键 改变分屏幕大小5个单位

vim使用
普通模式:

i 插入 a添加 o下一行插入

h j k l 四个方向移动游标

w,W 向后跳一个词 b,B 向前跳一个词

0 游标到行首 $游标至行尾

f " 找到该行向后双引号 f x 找到下一个字母x F相反

t " 找到该行向后双引号前一个位置 t x 找字母 T相反

{ }上下段落

v i " 选取目前游标所在的这个双引号内的内容 "hello world" 选中hello world

v i w 选取游标所在词

g g 整个文件第一行 G 最后一行

z t 当前行放置屏幕上方 z b当前行放置屏幕下方

/ 搜索 n 下一个结果 N上个一个结果

* 搜索游标所在的词

D 删除游标位置后所有内容

x 删除一个字

. 重复上一个动作

dd 剪切整行

3dd 删除3行

yy 复制一行

3yy 复制3行,包含游标那行

p 粘贴 4p 粘贴4行

: w 保存

:q 离开 加!强制离开

:tabe 新开tab gT 切换tab

:new 水平分割窗口 :vnew 垂直分割窗口

ctrl+z vim放置后台 fg 恢复vim

vi -o a b 水平分割开启a,b文件 vi -O a b 垂直分割开启a,b

vi -p a b 以tab视窗开启

:bp 上一个开启的文件 :bn下一个开启的文件

:ls 查看buffer

:bd 关闭已经开启的buffer

:b3 切换至buffer里面编号为3的档案

:b 文件名 切换为buffer里指定文件名

:tab ba 已开启buffer转tab

:vsplit filename 垂直分割屏幕打开文件

:sp filename 水平分割

ctrl+w w h j k l 分屏切换 < > + - 分屏大小切换 c q 退出

通过寄存器实现不同文件之间复制:
举例:
doc1:"ayy :wq
doc2:"ap
查看寄存器::reg
a可以替换

vim 插件使用方法

ack.vim(已经被ag替换)
按, a 激活
:ack 待查内容 文件名

搜索结果中操作
  o    to open (same as enter)
  go   to preview file (open but maintain focus on ack.vim results)
  t    to open in new tab
  T    to open in new tab silently
  h    to open in horizontal split
  H    to open in horizontal split silently
  v    to open in vertical split
  gv   to open in vertical split silently
  q    to close the quickfix window


ag.vim

按, a 激活
:Ag 待查内容 路径


syntastic
源码检查插件

vim-gitgutter
按, g 激活

You don't have to do anything: it just works.

With one exception the plugin diffs your saved buffers, i.e. the files on disk. It produces the same result as running[code]git diff
on the command line. The exception is realtime updating: in this case the plugin diffs the (unsaved) buffer contents against the version in git.

You can explicitly turn vim-gitgutter off and on (defaults to on):

turn off with
:GitGutterDisable


turn on with
:GitGutterEnable


toggle with
:GitGutterToggle
.

And you can turn line highlighting on and off (defaults to off):

turn on with
:GitGutterLineHighlightsEnable


turn off with
:GitGutterLineHighlightsDisable


toggle with
:GitGutterLineHighlightsToggle
.

Furthermore you can jump between hunks:

jump to next hunk:
]h


jump to previous hunk:
[h
.

Both of those take a preceding count.

To set your own mappings for these, for example
gh
and
gH
:

nmap gh <Plug>GitGutterNextHunk
nmap gH <Plug>GitGutterPrevHunk


Finally, you can force vim-gitgutter to update its signs across all visible buffers with
:GitGutterAll
.

See the customisation section below for how to change the defaults.

Align
按, l 激活
对齐工具,还为研究具体用法

tagbar
按, ] 激活
利用ctags显示源码里函数变量等

ctrlp.vim
ctrl + p激活
很强大的文件查找插件

vim-indent-guides
缩进工具

greplace.vim
查找替换插件

vim-colors-solarized
vim的solarized配色

snipmate.vim
代码块补全

vim-fugitive
一款git插件

vim-repeat
替代 . 重复功能

nerdtree
树形文件浏览工具

vim-surround
进到visual mode并选取文字后S"把选取文字加上双引号
cs"' =把周围的双引号换成单引号
cs]) =把周围的方括号换成小括号
ds" =删除周围的双引号
cst =删除周围的tag
yss" =把整行加上双引号
yss( =把整行加上小括号,但小括号与内容会有空格存在
yss) =同上,但不会有空格
yss{ =把整行加上大括号,但大括号与内容会有空格存在
yss} =同上,但不会有空格

vim-indentobject
v i i 选取相同缩排层级的文字
v a i 同上,但会连带上一层级也一并

//以下还未细看

vim-ruby

vim-bundler


jshint.vim

vim-coffee-script


vim-javascript

vim-tmux-navigator

kwbdi.vim


vim-pastie

vim-unimpaired

matchit.zip


vim-commentary

vim-protobuf

vim-vividchalk
mustache.vim


vim-cucumber

vim-ragtag

vundle

vim-endwise

vim-rails

[b]vim-slim[/b]

[b][b]typescript-vim[/b][/b]

[b][b][b]vim-sensible[/b][/b][/b]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: