标签:类型 download arch expand 指定 none 样式 pam gbk
0、在虚拟机下安装ubuntu系统,我的电脑太low了,ubuntu18版本装不了,然后就换了16版本,安装完成后安装vmware-tools,这个百度即可
1、安装vim
sudo apt-get install -y vim
2、配置vim
cd /etc/vim //切换到vim安装目录下
vim vimrc //用vim打开vimrc 刚开始进入是出于命令模式,可以按下a切换到输入模式,右键->Paste
//粘贴完毕后按下Esc由输入模式进入命令模式->输入:wq->回车保存并退出
vimrc文件设置参考博客顺序:
粘贴的内容为:
1 " 显示行号 2 set number 3 " 显示标尺 4 set ruler 5 " 历史纪录 6 set history=1000 7 " 输入的命令显示出来,看的清楚些 8 set showcmd 9 " 状态行显示的内容 10 set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} 11 " 启动显示状态行1,总是显示状态行2 12 set laststatus=2 13 " 语法高亮显示 14 syntax on 15 set fileencodings=utf-8,gb2312,gbk,cp936,latin-1 16 set fileencoding=utf-8 17 set termencoding=utf-8 18 set fileformat=unix 19 set encoding=utf-8 20 " 配色方案 21 colorscheme desert 22 " 指定配色方案是256色 23 set t_Co=256 24 25 set wildmenu 26 27 " 去掉有关vi一致性模式,避免以前版本的一些bug和局限,解决backspace不能使用的问题 28 set nocompatible 29 set backspace=indent,eol,start 30 set backspace=2 31 32 " 启用自动对齐功能,把上一行的对齐格式应用到下一行 33 set autoindent 34 35 " 依据上面的格式,智能的选择对齐方式,对于类似C语言编写很有用处 36 set smartindent 37 38 " vim禁用自动备份 39 set nobackup 40 set nowritebackup 41 set noswapfile 42 43 " 用空格代替tab 44 set expandtab 45 46 " 设置显示制表符的空格字符个数,改进tab缩进值,默认为8,现改为4 47 set tabstop=4 48 49 " 统一缩进为4,方便在开启了et后使用退格(backspace)键,每次退格将删除X个空格 50 set softtabstop=4 51 52 " 设定自动缩进为4个字符,程序中自动缩进所使用的空白长度 53 set shiftwidth=4 54 55 " 设置帮助文件为中文(需要安装vimcdoc文档) 56 set helplang=cn 57 58 " 显示匹配的括号 59 set showmatch 60 61 " 文件缩进及tab个数 62 au FileType html,python,vim,javascript setl shiftwidth=4 63 au FileType html,python,vim,javascript setl tabstop=4 64 au FileType java,php setl shiftwidth=4 65 au FileType java,php setl tabstop=4 66 " 高亮搜索的字符串 67 set hlsearch 68 69 " 检测文件的类型 70 filetype on 71 filetype plugin on 72 filetype indent on 73 74 " C风格缩进 75 set cindent 76 set completeopt=longest,menu 77 78 " 功能设置 79 80 " 去掉输入错误提示声音 81 set noeb 82 " 自动保存 83 set autowrite 84 " 突出显示当前行 85 set cursorline 86 " 突出显示当前列 87 set cursorcolumn 88 "设置光标样式为竖线vertical bar 89 " Change cursor shape between insert and normal mode in iTerm2.app 90 "if $TERM_PROGRAM =~ "iTerm" 91 let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode 92 let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode 93 "endif 94 " 共享剪贴板 95 set clipboard+=unnamed 96 " 文件被改动时自动载入 97 set autoread 98 " 顶部底部保持3行距离 99 set scrolloff=3
vimrc文件配置以上参考博客链接
以上的vim配置方法会在当前行和列显示白线条,去掉的方法为:
cd /etc/vim //转到vim安装目录下
vim vimrc //打开vimrc,删掉set cursorline 和set cursorcolum
另外vimrc详细配置参考博客
最后使用cim输入cpp文件的效果如下:
2、安装g++和gcc编译器
在安装之前可以使用以下命令先检查一下存在g++和gcc与否
g++ version
gcc version
如果没有使用如下命令进行安装
cd ..
cd ..
cd .. //退出vim安装路径
sudo apt-get install -y g++
sudo apt-get install -y gcc
至此编译环境安装成功
3、创建一个cpp文件
cd /home //切换到home目录下
mkdir test //在home目录下创建一个test文件夹
cd test //进入刚刚创建的test文件夹下
vim test.cpp //创建cpp文件,有可能会有问题,直接回车即可
//然后按下a由命令模式进入输入模式,输入完毕后,按下Esc由输入模式进入命令模式->:wq->回车,保存并退出
g++ -o test test.cpp //编译,注意必须要有test.cpp所在的路径
./test //输出hello world
1 yiya@YiYA:~$ sudo apt-get install -y vim 2 [sudo] password for yiya: 3 Reading package lists... Done 4 Building dependency tree 5 Reading state information... Done 6 The following additional packages will be installed: 7 vim-common vim-runtime vim-tiny 8 Suggested packages: 9 ctags vim-doc vim-scripts vim-gnome-py2 | vim-gtk-py2 | vim-gtk3-py2 10 | vim-athena-py2 | vim-nox-py2 indent 11 The following NEW packages will be installed: 12 vim vim-runtime 13 The following packages will be upgraded: 14 vim-common vim-tiny 15 2 upgraded, 2 newly installed, 0 to remove and 335 not upgraded. 16 Need to get 6,755 kB of archives. 17 After this operation, 30.0 MB of additional disk space will be used. 18 Get:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim-tiny amd64 2:7.4.1689-3ubuntu1.4 [446 kB] 19 Get:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim-common amd64 2:7.4.1689-3ubuntu1.4 [103 kB] 20 Get:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim-runtime all 2:7.4.1689-3ubuntu1.4 [5,169 kB] 21 Get:4 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim amd64 2:7.4.1689-3ubuntu1.4 [1,036 kB] 22 Fetched 6,755 kB in 16s (411 kB/s) 23 (Reading database ... 177098 files and directories currently installed.) 24 Preparing to unpack .../vim-tiny_2%3a7.4.1689-3ubuntu1.4_amd64.deb ... 25 Unpacking vim-tiny (2:7.4.1689-3ubuntu1.4) over (2:7.4.1689-3ubuntu1.2) ... 26 Preparing to unpack .../vim-common_2%3a7.4.1689-3ubuntu1.4_amd64.deb ... 27 Unpacking vim-common (2:7.4.1689-3ubuntu1.4) over (2:7.4.1689-3ubuntu1.2) ... 28 Selecting previously unselected package vim-runtime. 29 Preparing to unpack .../vim-runtime_2%3a7.4.1689-3ubuntu1.4_all.deb ... 30 Adding ‘diversion of /usr/share/vim/vim74/doc/help.txt to /usr/share/vim/vim74/doc/help.txt.vim-tiny by vim-runtime‘ 31 Adding ‘diversion of /usr/share/vim/vim74/doc/tags to /usr/share/vim/vim74/doc/tags.vim-tiny by vim-runtime‘ 32 Unpacking vim-runtime (2:7.4.1689-3ubuntu1.4) ... 33 Selecting previously unselected package vim. 34 Preparing to unpack .../vim_2%3a7.4.1689-3ubuntu1.4_amd64.deb ... 35 Unpacking vim (2:7.4.1689-3ubuntu1.4) ... 36 Processing triggers for man-db (2.7.5-1) ... 37 Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ... 38 Processing triggers for desktop-file-utils (0.22-1ubuntu5.2) ... 39 Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20180209-0ubuntu1) ... 40 Rebuilding /usr/share/applications/bamf-2.index... 41 Processing triggers for mime-support (3.59ubuntu1) ... 42 Processing triggers for hicolor-icon-theme (0.15-0ubuntu1.1) ... 43 Setting up vim-common (2:7.4.1689-3ubuntu1.4) ... 44 Setting up vim-tiny (2:7.4.1689-3ubuntu1.4) ... 45 Setting up vim-runtime (2:7.4.1689-3ubuntu1.4) ... 46 Setting up vim (2:7.4.1689-3ubuntu1.4) ... 47 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode 48 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode 49 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode 50 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode 51 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode 52 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode 53 update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode 54 yiya@YiYA:~$ ls 55 Desktop Downloads Music Public Videos 56 Documents examples.desktop Pictures Templates 57 yiya@YiYA:~$ sudo su 58 root@YiYA:/home/yiya# 123 59 123: command not found 60 root@YiYA:/home/yiya# ls 61 Desktop Downloads Music Public Videos 62 Documents examples.desktop Pictures Templates 63 root@YiYA:/home/yiya# cd /etc 64 root@YiYA:/etc# ls 65 acpi hosts profile.d 66 adduser.conf hosts.allow protocols 67 alternatives hosts.deny pulse 68 anacrontab hp python 69 apg.conf ifplugd python2.7 70 apm iftab python3 71 apparmor ImageMagick-6 python3.5 72 apparmor.d init rc0.d 73 apport init.d rc1.d 74 appstream.conf initramfs-tools rc2.d 75 apt inputrc rc3.d 76 aptdaemon insserv rc4.d 77 at-spi2 insserv.conf rc5.d 78 avahi insserv.conf.d rc6.d 79 bash.bashrc iproute2 rc.local 80 bash_completion issue rcS.d 81 bash_completion.d issue.net resolvconf 82 bindresvport.blacklist kbd resolv.conf 83 binfmt.d kernel rmt 84 bluetooth kernel-img.conf rpc 85 brlapi.key kerneloops.conf rsyslog.conf 86 brltty ldap rsyslog.d 87 brltty.conf ld.so.cache sane.d 88 ca-certificates ld.so.conf securetty 89 ca-certificates.conf ld.so.conf.d security 90 calendar legal selinux 91 chatscripts libao.conf sensors3.conf 92 compizconfig libaudit.conf sensors.d 93 console-setup libnl-3 services 94 cracklib libpaper.d sgml 95 cron.d libreoffice shadow 96 cron.daily lightdm shadow- 97 cron.hourly lintianrc shells 98 cron.monthly locale.alias signond.conf 99 crontab locale.gen signon-ui 100 cron.weekly localtime skel 101 cups logcheck speech-dispatcher 102 cupshelpers login.defs ssh 103 dbus-1 logrotate.conf ssl 104 dconf logrotate.d subgid 105 debconf.conf lsb-release subgid- 106 debian_version ltrace.conf subuid 107 default machine-id subuid- 108 deluser.conf magic sudoers 109 depmod.d magic.mime sudoers.d 110 dhcp mailcap sysctl.conf 111 dictionaries-common mailcap.order sysctl.d 112 dnsmasq.d manpath.config systemd 113 doc-base mime.types terminfo 114 dpkg mke2fs.conf thermald 115 drirc modprobe.d thunderbird 116 emacs modules timezone 117 environment modules-load.d tmpfiles.d 118 firefox mtab tpvmlp.conf 119 fonts mtools.conf ucf.conf 120 fstab nanorc udev 121 fuse.conf network udisks2 122 fwupd.conf NetworkManager ufw 123 gai.conf networks updatedb.conf 124 gconf newt update-manager 125 gdb nsswitch.conf update-motd.d 126 ghostscript opt update-notifier 127 gnome os-release UPower 128 gnome-app-install pam.conf upstart-xsessions 129 groff pam.d usb_modeswitch.conf 130 group papersize usb_modeswitch.d 131 group- passwd vim 132 grub.d passwd- vmware-caf 133 gshadow pcmcia vmware-tools 134 gshadow- perl vtrgb 135 gss pki wgetrc 136 gtk-2.0 pm wpa_supplicant 137 gtk-3.0 pnm2ppa.conf X11 138 guest-session polkit-1 xdg 139 hdparm.conf popularity-contest.conf xml 140 host.conf ppp zsh_command_not_found 141 hostname profile 142 root@YiYA:/etc# cd /vim 143 bash: cd: /vim: No such file or directory 144 root@YiYA:/etc# cd vim 145 root@YiYA:/etc/vim# ls 146 vimrc vimrc.tiny 147 root@YiYA:/etc/vim# vim vimrc 148 root@YiYA:/etc/vim# g++ version 149 g++: error: version: No such file or directory 150 g++: fatal error: no input files 151 compilation terminated. 152 root@YiYA:/etc/vim# gcc version 153 gcc: error: version: No such file or directory 154 gcc: fatal error: no input files 155 compilation terminated. 156 root@YiYA:/etc/vim# cd.. 157 cd..: command not found 158 root@YiYA:/etc/vim# cd .. 159 root@YiYA:/etc# cd .. 160 root@YiYA:/# cd .. 161 root@YiYA:/# sudo apt-get install -y g++ 162 Reading package lists... Done 163 Building dependency tree 164 Reading state information... Done 165 g++ is already the newest version (4:5.3.1-1ubuntu1). 166 0 upgraded, 0 newly installed, 0 to remove and 335 not upgraded. 167 root@YiYA:/# sudo apt-get install -y gcc 168 Reading package lists... Done 169 Building dependency tree 170 Reading state information... Done 171 gcc is already the newest version (4:5.3.1-1ubuntu1). 172 0 upgraded, 0 newly installed, 0 to remove and 335 not upgraded. 173 root@YiYA:/# ls 174 bin dev initrd.img lib64 mnt root snap tmp vmlinuz 175 boot etc initrd.img.old lost+found opt run srv usr 176 cdrom home lib media proc sbin sys var 177 root@YiYA:/# cd /home 178 root@YiYA:/home# ls 179 yiya 180 root@YiYA:/home# cd .. 181 root@YiYA:/# cd /Desptop 182 bash: cd: /Desptop: No such file or directory 183 root@YiYA:/# cd /home 184 root@YiYA:/home# cd /Desktop 185 bash: cd: /Desktop: No such file or directory 186 root@YiYA:/home# mkdir test 187 root@YiYA:/home# ls 188 test yiya 189 root@YiYA:/home# cd /test 190 bash: cd: /test: No such file or directory 191 root@YiYA:/home# cd test 192 root@YiYA:/home/test# vim test.cpp 193 Error detected while processing /usr/share/vim/vimrc: 194 line 56: 195 E518: Unknown option: histoty=1000 196 line 57: 197 E518: Unknown option: showmd 198 Press ENTER or type command to continue 199 root@YiYA:/home/test# g++ -o test.cpp 200 g++: fatal error: no input files 201 compilation terminated. 202 root@YiYA:/home/test# ./test 203 bash: ./test: No such file or directory 204 root@YiYA:/home/test# ls 205 test.cpp 206 root@YiYA:/home/test# vim test.cpp 207 Error detected while processing /usr/share/vim/vimrc: 208 line 56: 209 E518: Unknown option: histoty=1000 210 line 57: 211 E518: Unknown option: showmd 212 Press ENTER or type command to continue 213 root@YiYA:/home/test# g++ -o test.cpp 214 g++: fatal error: no input files 215 compilation terminated. 216 root@YiYA:/home/test# g++ -o test test.cpp 217 root@YiYA:/home/test# ./test 218 hello world! 219 root@YiYA:/home/test#
标签:类型 download arch expand 指定 none 样式 pam gbk
原文地址:https://www.cnblogs.com/YiYA-blog/p/12775937.html