linux下vim和bash配置文件 源文件

1. ~/.vimrc

"去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible
set autoread            " 文件修改之后自动载入
set completeopt=longest,menu      " 自动完成
set history=1000        "记录历史的行数
set backspace=2         " 设置退格键可用,正常处理indent, eol, start等
set vb t_vb=            "当vim进行编辑时,如果命令错误,会发出警报,该设置去掉警报  

filetype on             " 检测文件的类型
filetype plugin on         " 载入文件类型插件
filetype indent on        " 为特定文件类型载入相关缩进文件

" 主题,显示方面
set background=dark        "背景使用黑色
set showmatch            "设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号
set ruler               " 在状态行上显示光标所在位置的行号和列号
set showcmd                " 状态栏显示目前所执行的指令
set number                " 显示行号
syntax on                "语法高亮度显示
set cursorline           " 高亮光标所在的行
set report=0            " 通过使用: commands命令,告诉我们文件的哪一行被改变过
set shortmess=atI       " 启动的时候不显示那个援助索马里儿童的提示
set helplang=cn            " 中文

" 格式方面

"下面两行在进行编写代码时,在格式对起上很有用;
"第一行,vim使用自动对起,也就是把当前行的对起格式应用到下一行;
"第二行,依据上面的对起格式,智能的选择对起方式,对于类似C语言编
"写上很有用
"set cindent            "(cindent是特别针对 C语言语法自动缩进)
set autoindent
set smartindent
set paste                 " 粘贴时保持格式 

set tabstop=4            "第一行设置tab键为4个空格
set shiftwidth=4           "设置当行之间交错时使用4个空格
set softtabstop=4       " 按退格键时可以一次删掉 4 个空格
set noexpandtab            " 不要用空格代替制表符

"查询时非常方便,如要查找book单词,当输入到/b时,会自动找到第一
"个b开头的单词,当输入到/bo时,会自动找到第一个bo开头的单词,依
"次类推,进行查找时,使用此设置会快速找到答案,当你找要匹配的单词
"时,别忘记回车
set incsearch
set hlsearch
set ic                  " ignorecase

" 编码
set encoding=utf-8
set fileencodings=utf-8,GBK,GB18030,big5
set termencoding=utf-8

" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)
set mouse=a
set mouse=v
set selection=exclusive
set selectmode=mouse,key

" 用空格键来开关折叠
set foldenable
set foldmethod=manual
nnoremap  @=((foldclosed(line(‘.‘)) < 0) ? ‘zc‘ : ‘zo‘)
"set foldmethod=indent

"修改一个文件后,自动进行备份,备份的文件名为原文件名加"~"后缀
"if has("vms") "注意双引号要用半角的引号" "
"   set nobackup
"else
"   set backup
"endif

"set wildmenu        " 增强模式中的命令行自动完成操作
"autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
"autocmd FileType python set omnifunc=pythoncomplete#Complete
"autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
"autocmd FileType css set omnifunc=csscomplete#CompleteCSS
"autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
"autocmd FileType java set omnifunc=javacomplete#Complet

" TList
"let Tlist_Use_LEFT_Window=1
"let Tlist_File_Fold_Auto_Close=1
"let Tlist_Show_One_File=1
"let Tlist_GainFocus_On_ToggleOpen=1
"let Tlist_Exit_OnlyWindow=1
"let g:winManagerWindowLayout=‘FileExplorer‘

"nmap tl :Tlist<cr>
"map <space> <ESC><C-g>

2. ~/.bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don‘t do anything
[ -z "$PS1" ] && return

# don‘t put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don‘t overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it‘s compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1=‘${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ‘
else
    PS1=‘${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$ ‘
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to [email protected]:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\[email protected]\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls=‘ls --color=auto‘
    #alias dir=‘dir --color=auto‘
    #alias vdir=‘vdir --color=auto‘

    alias grep=‘grep --color=auto‘
    alias fgrep=‘fgrep --color=auto‘
    alias egrep=‘egrep --color=auto‘
fi

# some more ls aliases
alias ll=‘ls -alF‘
alias la=‘ls -A‘
alias l=‘ls -CF‘
alias s=‘sudo shutdown -h 0‘
alias m=‘sudo mentohust‘

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert=‘notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e ‘\‘‘s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//‘\‘‘)"‘

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don‘t need to enable
# this, if it‘s already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

3. /etc/bash.bashrc

# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don‘t do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1=‘${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$ ‘

# Commented out, don‘t overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to [email protected]:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND=‘echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"‘
#    ;;
#*)
#    ;;
#esac

# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#    . /etc/bash_completion
#fi

# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
    case " $(groups) " in *\ admin\ *)
    if [ -x /usr/bin/sudo ]; then
    cat <<-EOF
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.

    EOF
    fi
    esac
fi

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
    function command_not_found_handle {
            # check because c-n-f could‘ve been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
           /usr/bin/python /usr/lib/command-not-found -- "$1"
                   return $?
                elif [ -x /usr/share/command-not-found/command-not-found ]; then
           /usr/bin/python /usr/share/command-not-found/command-not-found -- "$1"
                   return $?
        else
           printf "%s: command not found\n" "$1" >&2
           return 127
        fi
    }
fi

时间: 2024-10-07 13:26:28

linux下vim和bash配置文件 源文件的相关文章

Linux 下vim 不能进行保存

折腾了一个中午,在终端输入  vim myProgram 然后编辑以下内容 #!/bin/bash clear echo "" echo "The Telephone Book" echo "" echo "1.Display A Telephone Number" ehco "2.Add A New Telephone Number" echo "" echo "Q Quit

linux下重要的网络配置文件

linux下重要的网络配置文件:一; /etc/sysconfig/network  文件内容: NETWORKING=yes                                <== yes启动网络no关闭网络 HOSTNAME=hostname                             <== 主机名 GATEWAY=192.168.1.1                           <== 默认网关 这个文件的主要功能是设置主机名(HostName

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

在日常业务运维中,有时为了配合解决问题,需要给非运维人员开通系统账号,用于查询日志或代码.通常为了系统安全或避免不必要的误操作等目的,会将账号权限降至最低.下面介绍下在Linux下通过受限bash创建指定权限账号的操作记录: [[email protected] ~]# ln -s /bin/bash /bin/rbash [[email protected] ~]# useradd -s /bin/rbash wangshibo [[email protected] ~]# passwd wa

linux下vim命令汇总

一. 进入vi的命令 vi filename : 打开或新建文件,并将光标置于第一行首 vi +n filename : 打开文件,并将光标置于第n行首 vi + filename : 打开文件,并将光标置于最后一行首 vi +/xxx filename:打开文件,并将光标置于第一个与xxx匹配的串处 vi -r filename : 在上次正用vi编辑时发生系统崩溃,恢复filename vi filename....filename :打开多个文件,依次进行编辑 二. 移动光标类命令 h :

二十八、Linux下Vim工具常用命令

在linux下做开发,甚至是只做管理维护工作,也少不了Vim的使用.作为一个新手,我也是刚刚接触,本节将我日常使用或收集的Vim常用命令记录下来. 当然,直接在命令行上输入:vimtutor,就可以学习到Vim的所有命令了.Vim很强大,很多牛人在vim里集成很多插件什么的,但这里只介绍基本vim命令 移动命令 h "左 j "下 k "上 l "右 w "光标移动到下一个单词的首字符 a word forward b "光标移动到上一个单词的首

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

nginx的配置放在nginx.conf文件中,一般我们可以使用以下命令查看服务器中存在的nginx.conf文件. locate nginx.conf /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf.default ... 如果服务器中存在多个nginx.conf文件,我们并不知道实际上调用的是哪个配置文件,因此我们必须找到实际调用的配置文件才能进行修改. 查看nginx实际调用的配置文件 1.查看nginx路径

linux下vim,find

8-30Study vim文本编辑工具: vim分为三种模式:编辑模式,插入模式,末行模式 编辑模式: d:删除字符 dd:删除整行 y:复制字符 yy粘贴整行 zz:保存退出 x:剪切单个字符 #x: 剪切x个字符 r 替换字符  6rT 表示当前光标往后6字符全部替换为T d^ 删除光标所在处到行首 d$删除光标所在处至行尾字符(同D) dw,de,db 删除单词,支持#来指明涵盖单词个数 行级别的粘贴: p:当前所在光标下一行粘贴 P:当前所在光标上一行粘贴 不到行级别: p:直接粘贴在当

linux下vim编辑器使用

VIM - Vi IMproved: vim是vi编辑器的升级版,是linux下标准的编辑器,具有程序编写能力,可以根据字体颜色辨别语法的正确性,方便程序的设计. 使用: # vim [OPTION]... FILE... +#:打开文件后,直接让光标处于第#行的行首 +/PATTERN:打开文件后,直接让光标处于第一个被PATTERN匹配到的行的行首 基本模式: 编辑模式(命令模式):打开文件的默认模式,可以上下左右键移动光标,复制粘贴删除数据 输入模式:编辑模式下按i,I,o,O,a,A等进

linux下vim命令详解

非常详细的介绍linux中vim的操作命令. 高级一些的编辑器,都会包含宏功能,vim当然不能缺少了,在vim中使用宏是非常方便的: :qx     开始记录宏,并将结果存入寄存器x q     退出记录模式 @x     播放记录在x寄存器中的宏命令 稍微解释一下,当在normal模式下输入:qx后,你对文本的所有编辑动作将会被记录下来,再次输入q即退出了记录模 式,然后输入@x对刚才记录下来的命令进行重复,此命令后可跟数字,表示要重复多少次,比如@x20,可以重复20次.这个在文本的批处理中