1.注释版  ~/.vimrc

  1. "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
  2. set nocompatible
  3. set autoread " 文件修改之后自动载入
  4. set completeopt=longest,menu " 自动完成
  5. set history= "记录历史的行数
  6. set backspace= " 设置退格键可用,正常处理indent, eol, start等
  7. set vb t_vb= "vim进行编辑时,如果命令错误,会发出警报,该设置去掉警报
  8.  
  9. filetype on " 检测文件的类型
  10. filetype plugin on " 载入文件类型插件
  11. filetype indent on " 为特定文件类型载入相关缩进文件
  12.  
  13. " 主题,显示方面
  14. set background=dark "背景使用黑色
  15. set showmatch "设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号
  16. set ruler " 在状态行上显示光标所在位置的行号和列号
  17. set showcmd " 状态栏显示目前所执行的指令
  18. set number " 显示行号
  19. syntax on "语法高亮度显示
  20. set cursorline " 高亮光标所在的行
  21. set report= " 通过使用: commands命令,告诉我们文件的哪一行被改变过
  22. set shortmess=atI " 启动的时候不显示那个援助索马里儿童的提示
  23. set helplang=cn " 中文
  24.  
  25. " 格式方面
  26.  
  27. "下面两行在进行编写代码时,在格式对起上很有用;
  28. "第一行,vim使用自动对起,也就是把当前行的对起格式应用到下一行;
  29. "第二行,依据上面的对起格式,智能的选择对起方式,对于类似C语言编
  30. "写上很有用
  31. "set cindent "(cindent是特别针对 C语言语法自动缩进)
  32. set autoindent
  33. set smartindent
  34. set paste " 粘贴时保持格式
  35.  
  36. set tabstop= "第一行设置tab键为4个空格
  37. set shiftwidth= "设置当行之间交错时使用4个空格
  38. set softtabstop= " 按退格键时可以一次删掉 4 个空格
  39. set noexpandtab " 不要用空格代替制表符
  40.  
  41. "查询时非常方便,如要查找book单词,当输入到/b时,会自动找到第一
  42. "b开头的单词,当输入到/bo时,会自动找到第一个bo开头的单词,依
  43. "次类推,进行查找时,使用此设置会快速找到答案,当你找要匹配的单词
  44. "时,别忘记回车
  45. set incsearch
  46. set hlsearch
  47. set ic " ignorecase
  48.  
  49. " 编码
  50. set encoding=utf-
  51. set fileencodings=utf-,GBK,GB18030,big5
  52. set termencoding=utf-
  53.  
  54. " 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
  55. set mouse=a
  56. set mouse=v
  57. set selection=exclusive
  58. set selectmode=mouse,key
  59.  
  60. " 用空格键来开关折叠
  61. set foldenable
  62. set foldmethod=manual
  63. nnoremap @=((foldclosed(line('.')) < ) ? 'zc' : 'zo')
  64. "set foldmethod=indent
  65.  
  66. "修改一个文件后,自动进行备份,备份的文件名为原文件名加"~"后缀
  67. "if has("vms") "注意双引号要用半角的引号" "
  68. " set nobackup
  69. "else
  70. " set backup
  71. "endif
  72.  
  73. "set wildmenu " 增强模式中的命令行自动完成操作
  74. "autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
  75. "autocmd FileType python set omnifunc=pythoncomplete#Complete
  76. "autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
  77. "autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
  78. "autocmd FileType css set omnifunc=csscomplete#CompleteCSS
  79. "autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
  80. "autocmd FileType java set omnifunc=javacomplete#Complet
  81.  
  82. " TList
  83. "let Tlist_Use_LEFT_Window=1
  84. "let Tlist_File_Fold_Auto_Close=1
  85. "let Tlist_Show_One_File=1
  86. "let Tlist_GainFocus_On_ToggleOpen=1
  87. "let Tlist_Exit_OnlyWindow=1
  88. "let g:winManagerWindowLayout='FileExplorer'
  89.  
  90. "nmap tl :Tlist<cr>
  91. "map <space> <ESC><C-g>

2.经典版  ~/.vimrc

  1. # ~/.bashrc: executed by bash() for non-login shells.
  2. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
  3. # for examples
  4.  
  5. # If not running interactively, don't do anything
  6. [ -z "$PS1" ] && return
  7.  
  8. # don't put duplicate lines in the history. See bash(1) for more options
  9. # ... or force ignoredups and ignorespace
  10. HISTCONTROL=ignoredups:ignorespace
  11.  
  12. # append to the history file, don't overwrite it
  13. shopt -s histappend
  14.  
  15. # for setting history length see HISTSIZE and HISTFILESIZE in bash()
  16. HISTSIZE=
  17. HISTFILESIZE=
  18.  
  19. # check the window size after each command and, if necessary,
  20. # update the values of LINES and COLUMNS.
  21. shopt -s checkwinsize
  22.  
  23. # make less more friendly for non-text input files, see lesspipe()
  24. [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
  25.  
  26. # set variable identifying the chroot you work in (used in the prompt below)
  27. if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
  28. debian_chroot=$(cat /etc/debian_chroot)
  29. fi
  30.  
  31. # set a fancy prompt (non-color, unless we know we "want" color)
  32. case "$TERM" in
  33. xterm-color) color_prompt=yes;;
  34. esac
  35.  
  36. # uncomment for a colored prompt, if the terminal has the capability; turned
  37. # off by default to not distract the user: the focus in a terminal window
  38. # should be on the output of commands, not on the prompt
  39. force_color_prompt=yes
  40.  
  41. if [ -n "$force_color_prompt" ]; then
  42. if [ -x /usr/bin/tput ] && tput setaf >&/dev/null; then
  43. # We have color support; assume it's compliant with Ecma-48
  44. # (ISO/IEC-). (Lack of such support is extremely rare, and such
  45. # a case would tend to support setf rather than setaf.)
  46. color_prompt=yes
  47. else
  48. color_prompt=
  49. fi
  50. fi
  51.  
  52. if [ "$color_prompt" = yes ]; then
  53. PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  54. else
  55. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  56. fi
  57. unset color_prompt force_color_prompt
  58.  
  59. # If this is an xterm set the title to user@host:dir
  60. case "$TERM" in
  61. xterm*|rxvt*)
  62. PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  63. ;;
  64. *)
  65. ;;
  66. esac
  67.  
  68. # enable color support of ls and also add handy aliases
  69. if [ -x /usr/bin/dircolors ]; then
  70. test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
  71. alias ls='ls --color=auto'
  72. #alias dir='dir --color=auto'
  73. #alias vdir='vdir --color=auto'
  74.  
  75. alias grep='grep --color=auto'
  76. alias fgrep='fgrep --color=auto'
  77. alias egrep='egrep --color=auto'
  78. fi
  79.  
  80. # some more ls aliases
  81. alias ll='ls -alF'
  82. alias la='ls -A'
  83. alias l='ls -CF'
  84. alias s='sudo shutdown -h 0'
  85. alias m='sudo mentohust'
  86.  
  87. # Add an "alert" alias for long running commands. Use like so:
  88. # sleep ; alert
  89. alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[-]\+\s*//;s/[;&|]\s*alert$//'\'')"'
  90.  
  91. # Alias definitions.
  92. # You may want to put all your additions into a separate file like
  93. # ~/.bash_aliases, instead of adding them here directly.
  94. # See /usr/share/doc/bash-doc/examples in the bash-doc package.
  95.  
  96. if [ -f ~/.bash_aliases ]; then
  97. . ~/.bash_aliases
  98. fi
  99.  
  100. # enable programmable completion features (you don't need to enable
  101. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
  102. # sources /etc/bash.bashrc).
  103. if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
  104. . /etc/bash_completion
  105. fi

3. /etc/bash.bashrc

  1. # System-wide .bashrc file for interactive bash() shells.
  2.  
  3. # To enable the settings / commands in this file for login shells as well,
  4. # this file has to be sourced in /etc/profile.
  5.  
  6. # If not running interactively, don't do anything
  7. [ -z "$PS1" ] && return
  8.  
  9. # check the window size after each command and, if necessary,
  10. # update the values of LINES and COLUMNS.
  11. shopt -s checkwinsize
  12.  
  13. # set variable identifying the chroot you work in (used in the prompt below)
  14. if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
  15. debian_chroot=$(cat /etc/debian_chroot)
  16. fi
  17.  
  18. # set a fancy prompt (non-color, overwrite the one in /etc/profile)
  19. PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
  20.  
  21. # Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
  22. # If this is an xterm set the title to user@host:dir
  23. #case "$TERM" in
  24. #xterm*|rxvt*)
  25. # PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
  26. # ;;
  27. #*)
  28. # ;;
  29. #esac
  30.  
  31. # enable bash completion in interactive shells
  32. #if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
  33. # . /etc/bash_completion
  34. #fi
  35.  
  36. # sudo hint
  37. if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
  38. case " $(groups) " in *\ admin\ *)
  39. if [ -x /usr/bin/sudo ]; then
  40. cat <<-EOF
  41. To run a command as administrator (user "root"), use "sudo <command>".
  42. See "man sudo_root" for details.
  43.  
  44. EOF
  45. fi
  46. esac
  47. fi
  48.  
  49. # if the command-not-found package is installed, use it
  50. if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
  51. function command_not_found_handle {
  52. # check because c-n-f could've been removed in the meantime
  53. if [ -x /usr/lib/command-not-found ]; then
  54. /usr/bin/python /usr/lib/command-not-found -- "$1"
  55. return $?
  56. elif [ -x /usr/share/command-not-found/command-not-found ]; then
  57. /usr/bin/python /usr/share/command-not-found/command-not-found -- "$1"
  58. return $?
  59. else
  60. printf "%s: command not found\n" "$1" >&
  61. return
  62. fi
  63. }
  64. fi

(转) linux下vim和bash配置文件的更多相关文章

  1. Linux下通过受限bash创建指定权限的账号

    在日常业务运维中,有时为了配合解决问题,需要给非运维人员开通系统账号,用于查询日志或代码.通常为了系统安全或避免不必要的误操作等目的,会将账号权限降至最低.下面介绍下在Linux下通过受限bash创建 ...

  2. linux下重要的网络配置文件

    linux下重要的网络配置文件:一; /etc/sysconfig/network  文件内容: NETWORKING=yes                                <= ...

  3. linux 下vim文件乱码 cat文件正常处理方法

    linux 下vim文件乱码 cat文件正常处理方法 服务器支持中文字符集,cat和其他查看文件命令现在正常,vim还是出现了中文乱码问题, 1.查看文件编码格式 vim 文件 :set fileen ...

  4. Linux下vim文件未正常退出,修复文件

    Linux下vim文件未正常退出,会产生一个 .文件名.swp的文件 ls -al  ,rm   删掉.swp文件 之后就可以正常使用文件了

  5. Linux下的sudo及其配置文件/etc/sudoers的详细配置说明

    http://www.osedu.net/article/linux/2011-01-03/178.html Linux下的sudo及其配置文件/etc/sudoers的详细配置说明 1.sudo介绍 ...

  6. 20145234黄斐《信息安全系统设计基础》第八周(Linux下vim相关命令)

    Linux下vim相关命令 在编辑程序时经常使用vim,所以记住一些常用的指令还是很有必要的 文件命令 vim file 打开单个文件vim file vim file1 file2 file3 .. ...

  7. linux下如何查找nginx配置文件的位置

    nginx的配置放在nginx.conf文件中,一般我们可以使用以下命令查看服务器中存在的nginx.conf文件. locate nginx.conf /usr/local/etc/nginx/ng ...

  8. MySQL入门——Linux下安装后的配置文件

    MySQL入门——Linux下安装后的配置文件 摘要:本文主要了解了在Linux环境下安装MySQL后的配置文件的位置,以及如何创建配置文件. 查看配置文件的加载顺序 找到mysqld的路径 通过wh ...

  9. Linux下Vim常用操作

    linux下Vim的常用操作 linux ​ 首先\(ctrl+Alt+t\)打开小框框 ​ \(./\):相当于手机上的\(home\)键 ​ \(ls\):当前文件夹的东东 ​ \(mkdir\) ...

随机推荐

  1. 第二阶段每日站立会议Third Day

    昨天对图片显示的大小进行调整 今天对于程序中的字体显示进行细化修改,使界面更美观 遇到的问题:当图片太小时,显示一块灰色区域,不美观

  2. 2018软工实践—Beta冲刺(3)

    队名 火箭少男100 组长博客 林燊大哥 作业博客 Beta 冲鸭鸭鸭! 成员冲刺阶段情况 林燊(组长) 过去两天完成了哪些任务 软件接口编写修正 自动化测试脚本编写 技术文稿更新 展示GitHub当 ...

  3. 批量梯度下降(BGD)、随机梯度下降(SGD)以及小批量梯度下降(MBGD)的理解

      梯度下降法作为机器学习中较常使用的优化算法,其有着三种不同的形式:批量梯度下降(Batch Gradient Descent).随机梯度下降(Stochastic Gradient Descent ...

  4. windows下的C++ socket服务器(2)

    int main(int ac, char *av[]) { ); ) { exit(); } thread t; ) { int socket_fd = accept(tcp_socket, nul ...

  5. Zookeeper的基础

    认识Zookeeper zookeeper是什么 分布式数据的一致性解决方案. Zookeeper 能做什么 数据发布和订阅(配置中心,config,disconf,diamond,appollo) ...

  6. 关于#pragma comment

    #pragma comment(lib,"ws2_32.lib") #pragma comment(lib,"ws2_32.lib")表示连接Ws2_32.li ...

  7. Redis 基础:Redis 数据类型

    Redis 数据类型 Redis支持五种数据类型:string(字符串).hash(哈希).list(列表).set(集合)及zset(sorted set:有序集合). String(字符串) st ...

  8. 014 Java的反射机制

    作者:nnngu GitHub:https://github.com/nnngu 博客园:http://www.cnblogs.com/nnngu 简书:https://www.jianshu.com ...

  9. idea建立web项目servlet映射的地址/jsp访问不到

    用IntelliJ IDEA 2017新建了一个web项目,成功运行后servlet mapping的地址一直访问不到 原因:在配置tomcat的时候Server中Open browser选项勾选之后 ...

  10. win7下解决烦人的管理员权限问题

    禁不住诱惑,用上win7了.可是,对system下的文件进行编辑时候,老是碰到什么必须拥有管理员权限才能进行操作,删除文件或者文件夹也遇到一样的问题.我就纳闷了,我不就是超级管理员吗?我怎么就没有权限 ...