51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Debian 初始化成主力系统

效果图 {#效果图}

同样适用于 Ubuntu

一、优化 Debian {#一、优化-Debian}

1、系统配置 {#1、系统配置}

(1)安装常用的命令 {#(1)安装常用的命令}

|-------------|----------------------------------------------------------------------------------| | 1 2 | su root apt -y install net-tools gcc curl wget vim htop git unzip expect |

(2)恢复 sudo 权限 {#(2)恢复-sudo-权限}

执行sudo时提示"XXX 不在sudoers文件中,此事将被报告"

因为能执行sudo权限的用户都在/etc/sudoers文件中做了设置的。

修改方法:

1、使用root账号,输入su,再输入root密码后就可以操作了,不需要sudo命令

2、修改sudoers增加权限

修改/etc/sudoers文件权限,并打开文件

|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 | root@debian-11:/home/debian # ls -l /etc/sudoers -r--r----- 1 root root 669 2月 27 2021 /etc/sudoers root@debian-11:/home/debian # chmod u+w /etc/sudoers root@debian-11:/home/debian # ls -l /etc/sudoers -rw-r----- 1 root root 669 2月 27 2021 /etc/sudoers root@debian-11:/home/debian # vim /etc/sudoers |

找到root ALL=(ALL:ALL) ALL这行,在下方添加自己的账户并:wq!进行强制保存退出,如debianALL=(ALL:ALL) ALL

微信截图_20230113143034

3、再次修改/etc/sudoers文件权限

|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 | root@debian-11:/home/debian # chmod 440 /etc/sudoers root@debian-11:/home/debian # ls -l /etc/sudoers -r--r----- 1 root root 695 1月 13 14:30 /etc/sudoers |

4、至此可以在用户staryu下运行sudo,但是部分文件或文件夹权限还是要自己修改的。

(3)更换国内源 {#(3)更换国内源}

因为在国内使用,使用官网的源镜像会有时候会导致下载非常的慢,所以我们要更换为国内的源镜像

这里我使用的是 清华大学开源软件镜像站 的镜像

微信截图_20230113140408

更换源:

|---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # 首先备份源镜像文件 sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup # 修改 sources.list 文件 sudo gedit /etc/apt/sources.list # 把里面的都注释掉,在最后面加入清华源: # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free # 保存文件并退出,然后刷新软件源 sudo apt update |

将home目录下文件夹更改为对应的英文 {#将home目录下文件夹更改为对应的英文}

因为安装的时候选择的是中文,中文环境下home目录下文件夹显示的是中文,不方便使用cd命令,用到的软件xdg-user-dirs-gtk(Gnome 环境已默认安装),可以方便更改为英文

|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 | #临时转换系统语言为英文,重启后会自动恢复原值的 export LANG=en_US #执行转换命令,弹出的窗口中会询问是否将目录转化为英文路径,同意并关闭 xdg-user-dirs-gtk-update #转换回系统语言为中文,也可以不执行下面的命令,直接重启也一样的 export LANG=zh_CN |

重启,会提示是否把目录转化为中文,选择不,并选择不再提示,并取消修改。

修改 .bashrc 文件 {#修改-bashrc-文件}

这里修改 .bashrc 文件是为了跟方便的使用命令行

直接使用我修改好的 .bashrc 文件即可(如有其他需要的可以直接更改)

|---------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 克隆配置文件 git clone https://github.com/sityliu/Linux_Config_File.git # 修改普通用户 .bashrc 文件 cd Linux_Config_File cp ~/.bashrc ~/.bashrc.backup cp Debian_user_.bashrc ~/.bashrc source ~/.bashrc # 修改 root 用户 .bashrc 文件 cd Linux_Config_File sudo cp /root/.bashrc /root/.bashrc.backup sudo cp Debian_root_.bashrc /root/.bashrc sudo -i |

安装输入法 {#安装输入法}

这里使用的是谷歌输入法,搜狗好像有一堆的小毛病.......

在Ubuntu 下,谷歌拼音输入法是基于Fcitx输入法的。因此,我们需要首先安装Fcitx。一般来说,Ubuntu最新版中都默认安装了Fcitx,但是为了确保一下,我们可以在系统终端中运行如下命令:

|-----------|--------------------------------| | 1 | sudo apt install fcitx |

配置Fcitx

|-----------|-------------------| | 1 | im-config |

注:im-config是Input Method Configuration的缩写。

运行如下命令之后,就会开启 Input Method Configuration 窗口

在出现的窗口中,选择OK.

在出来的这个窗口中,必须选中Fcitx,然后选择Yes

选中Fcitx后出来的窗口就选择OK,点击OK后就关闭窗口,重新启动电脑让所做的配置生效

然后安装谷歌拼音输入法(Google Pinyin)

|-----------|---------------------------------------------| | 1 | sudo apt install fcitx-googlepinyin |

安装后运行如下命令配置谷歌拼音输入法.

|-----------|---------------------------| | 1 | fcitx-config-gtk3 |

会打开Input Method Confuguration窗口,点击左下角 + 号,添加Google Pinyin输入法,如果没有找到就重启一次系统,就有了。

最后,用快捷键:Ctrl+空格 切换输入法,就能看到你已经能用谷歌拼音输入法打字了

卸载一些不常用的软件 {#卸载一些不常用的软件}

这里的话我们使用自带的软件商店来卸载不常用的软件

微信截图_20230113155428

安装常用的软件 {#安装常用的软件}

自收集的软件库链接: http://nas.lanmo.link:200/1_Linux_Software_Package

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | # 安装 edge 浏览器 cd Downloads/ wget https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_109.0.1518.49-1_amd64.deb sudo dpkg -i microsoft-edge-stable_109.0.1518.49-1_amd64.deb # 可能会出现依赖缺少,直接执行 sudo apt --fix-broken install # 安装微信 cd Downloads/ wget http://archive.ubuntukylin.com/software/pool/partner/weixin_2.1.1_amd64.deb sudo dpkg -i weixin_2.1.1_amd64.deb # 安装 QQ cd Downloads/ wget https://dldir1.qq.com/qqfile/qq/QQNT/c005c911/linuxqq_3.0.0-571_amd64.deb sudo dpkg -i linuxqq_3.0.0-571_amd64.deb # 如不想使用原生态的微信和QQ可以使用优麒麟的,基于 wine 的,这个版本的是已经经过优麒麟优化过的,比winehq稳定许多。 # 下载Wine环境包并安装(其需要安装一次就好) cd Downloads/ wget http://archive.ubuntukylin.com/software/pool/partner/ukylin-wine_70.6.3.25_amd64.deb sudo dpkg -i ukylin-wine_70.6.3.25_amd64.deb # 安装 wine 微信 wget http://archive.ubuntukylin.com/software/pool/partner/ukylin-wechat_3.0.0_amd64.deb sudo dpkg -i ukylin-wechat_3.0.0_amd64.deb # # 安装 wine QQ (太久没有更新了,不确定能不能使用) wget http://archive.ubuntukylin.com/software/pool/partner/ukylin-qq_1.0_amd64.deb sudo dpkg -i ukylin-qq_1.0_amd64.deb # 安装网易云音乐 cd Downloads/ wget https://d1.music.126.net/dmusic/netease-cloud-music_1.2.1_amd64_ubuntu_20190428.deb sudo dpkg -i netease-cloud-music_1.2.1_amd64_ubuntu_20190428.deb # 安装 WPS cd Downloads/ wget https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2019/11664/wps-office_11.1.0.11664_amd64.deb sudo dpkg -i wps-office_11.1.0.11664_amd64.deb # 解决 wps 字体缺失 # 下载缺失的字体 # 链接:https://pan.baidu.com/s/1jKzUJh5MxG2TkI8NyK5wfA 提取码:29nv mkdir wps_symbol_fonts unzip wps_symbol_fonts.zip -d ./wps_symbol_fonts cd wps-symbol-fonts cp * /usr/share/fonts sudo mkfontscale sudo mkfontdir sudo fc-cache # 安装 vscode cd Downloads/ wget https://vscode.download.prss.microsoft.com/dbazure/download/stable/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/code_1.85.1-1702462158_amd64.deb sudo dpkg -i code_1.74.3-1673284829_amd64.deb # 安装 Anaconda cd Downloads/ wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh chmod +x Anaconda3-2022.10-Linux-x86_64.sh ./Anaconda3-2022.10-Linux-x86_64.sh # 解决安装 Anaconda 后终端出现(base) # 直接加入 conda deactivate 进.bashrc文件发现终端启动慢了几秒 echo "conda deactivate" >> ~/.bashrc # 安装 Node.js cd Downloads/ wget https://nodejs.org/dist/v18.13.0/node-v18.13.0-linux-x64.tar.xz tar -xvf node-v18.13.0-linux-x64.tar.xz mkdir -p /opt/nodejs && cp -r node-v18.13.0-linux-x64/* /opt/nodejs ln -s /opt/nodejs/bin/np /bin/node ln -s /opt/nodejs/bin/npm /bin/npm # 安装 pycharm cd Downloads/ wget https://download.jetbrains.com.cn/python/pycharm-community-2022.3.1.tar.gz sudo tar -zxvf pycharm-community-2022.3.1.tar.gz -C /opt # 运行 pycharm bash /opt/pycharm-community-2022.3.1/bin/pycharm.sh # 设置桌面快捷方式 # 选择菜单Tools /Create Desktop Entry... ,设置任务栏启动图标 # 设置图标时需要勾选Create the entry for all users # 之后就可以通过应用程序中启动了。 # 安装 sublimetext wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list sudo apt-get update sudo apt-get install sublime-text # sublimetext 设置中文 1.打开Sublime Text,点击Preferences,接着点击上方Preferences,选择Package Control。 2.点击Install Package进入,稍等一下 3.输入Chinese找到安装包 4.找到中文安装包插件并点击安装 5.稍等一下就会更改为中文了(如果没有的话可以在Help,将鼠标悬浮在language,选择简体中文即可。) # 对于windows系统使用系统自带的txt编辑工具,默认打开和保存文件的文件的格式是GBK或者GB2312,而sublime默认仅支持utf-8,所以当从windows系统拷贝文件在mac上浏览有时候会出现乱码的问题,这时候就需要安装插件使submile对这两种编码格式进行支持 1. 输入快捷键ctr+ shift +p有如下显示: 2. 在命令行里面输入 install 下拉框中会有package install 模式,选中enter键进入 3. 然后在输入框中输入ConvertToUTF8,安装成功后会自动加载打开介绍文档和配置文件信息 4. 重新打开乱码文件,如果依然显示乱码或者步骤3中的配置文件提示:Encoding: GB2312 Error: Codecs missing,则需要安装Codecs插件,步骤同上,先进入package install 模式,然后输入Codecs33,安装完之后从新打开乱码文件即可。 # 安装 marktext cd Downloads/ wget https://github.com/marktext/marktext/releases/download/v0.17.1/marktext-amd64.deb sudo dpkg -i marktext-amd64.deb # 安装 DevSidecar cd Downloads/ wget https://github.com/docmirror/dev-sidecar/releases/download/v1.7.3/DevSidecar-1.7.3.deb sudo dpkg -i DevSidecar-1.7.3.deb # FinalShell Linux版安装及教程 # 一键安装脚本 rm -f finalshell_install_linux.sh ;wget www.hostbuf.com/downloads/finalshell_install_linux.sh; chmod +x finalshell_install_linux.sh;./finalshell_install_linux.sh; # 安装路径 /usr/lib/FinalShell/ # 配置文件路径 /home/ $USER /.finalshell/ # 卸载 # 删除安装目录 /usr/lib/FinalShell/ # 安装 XDM cd Downloads/ wget https://github.com/subhra74/xdm/releases/download/7.2.11/xdm-setup-7.2.11.tar.xz tar -xvf xdm-setup-7.2.11.tar.xz sudo ./install.sh # 安装向日葵远程 cd Downloads/ wget https://down.oray.com/sunlogin/linux/SunloginClient_11.0.1.44968_amd64.deb sudo dpkg -i SunloginClient_11.0.1.44968_amd64.deb # 安装录屏软件 sudo apt-get install simplescreenrecorder |

修改grub的启动时间 {#修改grub的启动时间}

grub的启动时间基本上是修改 /etc/default/grub

|---------------------------|--------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 | sudo -i vim /etc/default/grub # 修改等待时间 # 以上是10秒,可修改成想要的时间,0秒则开机不会显示grub 列表 GRUB_TIMEOUT=10 # 生效文件修改 update-grub2 |

二、美化 Debian {#二、美化-Debian}

修改终端 {#修改终端}

这里直接修改终端的配置文件即可

微信截图_20230113154537

我安装的是debian gnome桌面版。安装完成之后,没有快捷键可以方便的打开terminal,需要自己设置这个快捷键

设置==》键盘 ==》快捷键==》自定义快捷键

点击+号,后弹出一个添加对话框,进行如下填写;点击"添加"按钮进行添加。
微信截图_20230113155008

这样就可以使用快捷键启动终端了

开启窗口的最大化最小化 {#开启窗口的最大化最小化}

扩展---》窗口标题栏---》
屏幕截图 2023-01-14 011927

安装常用扩展 {#安装常用扩展}

|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # ubuntu20默认有个自带的ubuntu dock,需要先卸载,否则会产生冲突,导致dash to dock的设置不生效。 sudo apt-get autoremove --purge gnome-shell-extension-ubuntu-dock -y # 在使用 GNOME Shell 扩展之前,需要安装 GNOME Tweak Tool sudo apt install gnome-tweak-tool # 获取GNOME Shell 的版本 gnome-shell --version # 也可以使用 gnome-shell-extensions 包 sudo apt install gnome-shell-extensions # 从 Web 浏览器安装 GNOME Shell 扩展 # 如果出现 "尽管 GNOME Shell 集成扩展正在运行,但未检测到本地主机连接器。请参阅文档以获取有关安装连接器的信息。" # 这是因为尚未安装主机连接器,直接安装: sudo apt install chrome-gnome-shell # TopIcons Plus # 它可以把正在运行的程序的图标移动到顶部面板中 sudo apt install gnome-shell-extension-top-icons-plus # 通过 https://extensions.gnome.org/ 安装的扩展: # 火狐浏览器打开上面的网站,然后安装浏览器扩展,就可以直接搜索安装扩展了 # 常用的扩展 # Clipboard Indicator # Removable Drive Menu # Applications Menu # Dash to Dock # User icon displayed # Screenshot Tool # Blur my Shell (有一些小Bug) # 手动安装gnome-shell扩展组件 # a. 选择需要下载的组件,并选择对应的版本; # b. 下载后解压; # c. 将解压后的目录移到:~/.local/share/gnome-shell/extensions/ 下; # d. 打开对应扩展目录下的metadata.json文件,查看uuid; # e. 重命名刚才移过来的目录名为uuid中的内容; # f. 关闭并重新打开gnome-tweaks; # g. 如果仍然没有刷出来,使用alt + F2调出gnome-shell的命令行,并输入r后回车;然后重复步骤f; |

三、其他设置 {#三、其他设置}

vim 美化 {#vim-美化}

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | # 如果不存在 .vimrc 可以直接创建 gedit ~/.vimrc # 美化: # 在打开.vimrc 中输入以下 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " 显示相关 " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示 winpos 5 5 " 设定窗口位置 set lines=30 columns=110 " 设定窗口大小 set nu " 显示行号 set go= " 不要图形按钮 "color asmanian2 " 设置背景主题 set guifont=Courier_New:h10:cANSI " 设置字体 syntax on " 语法高亮 autocmd InsertLeave * se nocul " 用浅色高亮当前行 autocmd InsertEnter * se cul " 用浅色高亮当前行 set ruler " 显示标尺 set showcmd " 输入的命令显示出来,看的清楚些 set cmdheight=1 " 命令行(在状态行下)的高度,设置为1 " set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界(不建议) set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 set novisualbell " 不要闪烁(不明白) set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} " 状态行显示的内容 set laststatus=1 " 启动显示状态行(1),总是显示状态行(2) set foldenable " 允许折叠 set foldmethod=manual " 手动折叠 set background=dark " 背景使用黑色 set nocompatible "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限 " 显示中文帮助 if version >= 603 set helplang=cn set encoding=utf-8 endif " 设置配色方案 " colorscheme murphy "字体 " if (has( "gui_running" )) " set guifont=Bitstream\ Vera\ Sans\ Mono\ 10 " endif set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8 set fileencodings=ucs-bom,utf-8,cp936 set fileencoding=utf-8 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " " "" "" 新文件标题 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "新建.c,.h,.sh,.java文件,自动插入文件头 autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec " :call SetTitle() " " "定义函数SetTitle,自动插入文件头 func SetTitle() " 如果文件类型为.sh文件 if &filetype == 'sh' call setline(1, "\#########################################################################" ) call append(line( "." ), "\# File Name : " . expand ( "%" )) call append(line( "." )+1, "\# Author : 蓝陌" ) call append(line( "." )+2, "\# mail : sityliu@163.com" ) call append(line( "." )+3, "\# Created Time : " .strftime( "%c" )) call append(line( "." )+4, "\#########################################################################" ) call append(line( "." )+5, "" ) call append(line( "." )+6, "\#!/bin/bash" ) call append(line( "." )+7, "" ) call append(line( "." )+8, "" ) else call setline(1, "/*************************************************************************" ) call append(line( "." ), " > File Name : " . expand ( "%" )) call append(line( "." )+1, " > Author : 蓝陌" ) call append(line( "." )+2, " > Mail : sityliu@163.com " ) call append(line( "." )+3, " > Created Time : " .strftime( "%c" )) call append(line( "." )+4, " ************************************************************************/" ) call append(line( "." )+5, "" ) endif if &filetype == 'cpp' call append(line( "." )+6, "#include<iostream>" ) call append(line( "." )+7, "" ) call append(line( "." )+8, "using namespace std;" ) call append(line( "." )+9, "" ) call append(line( "." )+10, "int main(int argc,char *argv[])" ) call append(line( "." )+11, "{" ) call append(line( "." )+12, " " ) call append(line( "." )+13, " return 0;" ) call append(line( "." )+14, "}" ) endif if &filetype == 'c' call append(line( "." )+6, "#include<stdio.h>" ) call append(line( "." )+7, "" ) call append(line( "." )+8, "int main(int argc,char *argv[])" ) call append(line( "." )+9, "{" ) call append(line( "." )+10, " " ) call append(line( "." )+11, " return 0;" ) call append(line( "." )+12, "}" ) autocmd BufNewFile * 12 j endif endfunc "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "键盘命令 " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " " C,C++ 按F5编译运行 map <F5> :call CompileRunGcc()<CR> func! CompileRunGcc() exec "w" if &filetype == 'c' exec "!gcc % -o %<" exec "! ./%<" elseif &filetype == 'cpp' exec "!g++ % -o %<" exec "! ./%<" elseif &filetype == 'sh' :!./% endif endfunc "C,C++的调试 map <C-F5> :call Rungdb()<CR> func! Rungdb() exec " w " if &filetype == 'c' exec " !gcc % -g -o %< " exec " !gdb -tui ./%< " elseif &filetype == 'cpp' exec " !g++ % -g -o %< " exec " !gdb -tui ./%< " endif endfunc " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " " "实用设置 " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " 设置当文件被改动时自动载入 set autoread " quickfix模式 autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr> "代码补全 set completeopt=preview,menu " 允许插件 filetype plugin on "共享剪贴板 set clipboard+=unnamed " 从不备份 set nobackup "自动保存 set autowrite set ruler " 打开状态栏标尺 set cursorline " 突出显示当前行 set magic " 设置魔术 set guioptions-=T " 隐藏工具栏 set guioptions-=m " 隐藏菜单栏 set foldcolumn=0 set foldmethod=indent set foldlevel=3 set foldenable " 开始折叠 " 不要使用vi的键盘模式,而是vim自己的 set nocompatible " 语法高亮 set syntax=on " 去掉输入错误的提示声音 set noeb " 在处理未保存或只读文件的时候,弹出确认 set confirm " 自动缩进 set autoindent set cindent " Tab键的宽度 set tabstop=4 " 统一缩进为4 set softtabstop=4 set shiftwidth=4 "禁止生成临时文件 set nobackup set noswapfile " 搜索忽略大小写 set ignorecase "搜索逐字符高亮 set hlsearch set incsearch " 行内替换 set gdefault "编码设置 set enc=utf-8 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 " 语言设置 set langmenu=zh_CN.UTF-8 set helplang=cn " 我的状态行显示的内容(包括文件类型和解码) set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} " set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] "set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ " 总是显示状态行 set laststatus=2 " 命令行(在状态行下)的高度,默认为1,这里是2 set cmdheight=2 " 侦测文件类型 filetype on " 载入文件类型插件 filetype plugin on " 为特定文件类型载入相关缩进文件 filetype indent on " 保存全局变量 set viminfo+=! " 在被分割的窗口间显示空白,便于阅读 set fillchars=vert:\ ,stl:\ ,stlnc:\ " 高亮显示匹配的括号 set showmatch " 匹配括号高亮的时间(单位是十分之一秒) set matchtime=1 " 光标移动到buffer的顶部和底部时保持3行距离 set scrolloff=3 " 为C程序提供自动缩进 set smartindent " 高亮显示普通txt文件(需要txt.vim脚本) au BufRead,BufNewFile * setfiletype txt " 自动补全 ":inoremap ( ()<ESC>i " :inoremap ) <c-r>=ClosePair( ')' )<CR> :inoremap { {<CR>}<ESC>O :inoremap } <c-r>=ClosePair( '}' )<CR> ":inoremap [ []<ESC>i " :inoremap ] <c-r>=ClosePair( ']' )<CR> ":inoremap " "" <ESC>i ":inoremap ' ''<ESC>i function! ClosePair(char) if getline('.')[col('.') - 1] == a:char return " \<Right> " else return a:char endif endfunction filetype plugin indent on " 打开文件类型检测, 加了这句才可以用智能补全 set completeopt=longest,menu |

赞(0)
未经允许不得转载:工具盒子 » Debian 初始化成主力系统