mac vim shell配置

时间:2023-03-09 15:01:22
mac vim  shell配置

一 : vim 配置

1 目录/usr/share/vim/vimrc

2 Python 自动缩进

http://blog.****.net/ikerpeng/article/details/18663055

set filetype=python

au BufNewFile,BufRead *.py,*.pyw setf python
set autoindent " same level indent
set smartindent " next level indent
set expandtab
set tabstop=4
set shiftwidth=4

set softtabstop=4

3 vim配色

(1)推荐使用molokai配色  下载:http://www.vim.org/scripts/script.php?script_id=2340

(2) solarized https://github.com/altercation/solarized 还可以用于iTerm2

https://segmentfault.com/a/1190000002449640

ls /usr/share/vim/vim73/colors

大致输出如下:

README.txt    default.vim   elflord.vim   morning.vim   peachpuff.vim slate.vim
blue.vim delek.vim evening.vim murphy.vim ron.vim torte.vim
darkblue.vim desert.vim koehler.vim pablo.vim shine.vim zellner.vim

然后创建配置文件

jemy@jemy-MacBook ~/.vim $ cd ~
jemy@jemy-MacBook ~ $ vim .vimrc

.vimsrc的内容如下:

set nu
colorscheme desert

上面配置的意思是:

  1. set nu开启行号
  2. colorscheme desert设置配色方案为desert
 4 vim粘贴不缩进
http://www.cnblogs.com/end/archive/2012/06/01/2531142.html
 " Configuration file for vim
set modelines= " CVE-2007-2438
set nu
colorscheme molokai
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " Use Vim defaults instead of 100% vi compatibility
set backspace= " more powerful backspacing " Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup nobackup set filetype=python
au BufNewFile,BufRead *.py,*.pyw setf python
set autoindent " same level indent
set smartindent " next level indent
set expandtab
set tabstop=
set shiftwidth=
set softtabstop= syntax on

http://www.gocalf.com/blog/make-mac-better-for-development.html

http://equation85.github.io/blog/customize-terminal-on-mac/

http://www.vpsee.com/2013/09/use-the-solarized-color-theme-on-mac-os-x-terminal/

二: shell设置

http://linfan.info/blog/2012/02/27/colorful-terminal-in-mac/

http://chaishiwei.com/blog/247.html

与Linux相比,Mac OS X的终端总是欠缺些什么。对了,是色彩,Linux的ls命令使用不同颜色区分各种文件类型,Vim编辑器也支持语法高亮,而Mac终端却总是以黑白示人。其实,只要稍微做一些工作,Mac的终端同样可以多姿多彩,请往下看。

彩色化ls的输出

Mac中BSD的ls命令可以使用-G参数彩色化输出的文件列表,需要配置LSCOLORS环境变量定义颜色,具体配置方法可以输入man ls查看。

不过,我推荐安装Linux使用的GNU Coreutils替换Mac的ls命令,因为:

  • Coreutils提供了配置工具,定义颜色代码更加方便;
  • Coreutils包含的不仅仅是ls,同时作为Linux用户,我更习惯于使用GNU的各种shell工具。

Coreutils的安装与配置方法如下:

  1. 通过Homebrew安装Coreutils
    brew install xz coreutils
    注:Coreutils并不依赖于xz,但它的源码是用xz格式压缩的,安装xz才能解压。

  2. 生成颜色定义文件
    gdircolors --print-database > ~/.dir_colors

  3. ~/.bash_profile配置文件中加入以下代码

1
2
3
4
5
if brew list | grep coreutils > /dev/null ; then
PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
alias ls='ls -F --show-control-chars --color=auto'
eval `gdircolors -b $HOME/.dir_colors`
fi

gdircolor的作用就是设置ls命令使用的环境变量LS_COLORS(BSD是LSCOLORS),我们可以修改~/.dir_colors自定义文件的颜色,此文件中的注释已经包含各种颜色取值的说明。

看看默认颜色的显示效果。
mac vim  shell配置

grep高亮显示关键字

这个很简单,加上--color参数就可以了,为了使用方便,可以在~/.bash_profile配置文件中加上alias定义。

1
2
3
alias grep='grep --color'
alias egrep='egrep --color'
alias fgrep='fgrep --color'

Vim语法高亮

在Vim中输入命令:syntax on激活语法高亮,若需要Vim启动时自动激活,在~/.vimrc中添加一行syntax on即可。