linux & Gvim 常用命令

linux & Gvim 常用命令

Gvim常用命令

# ------ open a file -----------
vi file_name   : open a file for editing on a terminal
vim file_name  :
gvim file_name : gvim is a GUI of vi

# when open a file , vi is in insert mode by default

i     	: go to insert mode 
esc    	: go to command mode
:w     	: write into the file (save)
:q     	: quit vi 
:q!    	: force to quit and abort the modification
:wq    	: save and quit

# ----- move cursor ------------
->/<-     : left/right/up/down 
h|j|k|l   : h(left)| j(down) | k(up) l (right)
          : 3h | 4j | 5k | 6l
:w        : move forward one word eg. 3w
:b        : move backward one word eg. 4b
:$        : move to the end of a line
:^|0      : move to the beginning of a line
# ---------------------------

gg          : go to the first line
G           : go to the last line
nG          : go to n line eg. 1G
:number     :
:set nu     : set number line
:set nonu
CTRL + G    : display the current line and total numbers of lines
CTRL + U    : page up
CTRL + D    : page down

# ----- delete copy and paste -----

d=delete, y=copy, p=paste

dd       : delete a line eg. 5dd
dw       : delete a word eg. d3w
d0       : 
d$       : delete to end of line

yy       : copy a line et. 5yy
yw 
y0 
y$ 
Y        	: copy
:5,10y    	: copy 5 ~ 10 line
:,10y     	: copy cursor ~ 10 line
:5,y      	: copy 5 ~ cursor line

:p        : paste

:.        : rpeat last operation 

:x        : dlete a character eg. 3x

# ------ undo the editing  ----
:u|U      : undo | redo
:CTRL+R   : ned the modification

# ------ inset cursor -------------------
a|A       : ater the cursor | end of a line
o|O       : input one new line under the current line | up the current line
:help a   : 

# ------ search  ---------------------
:/pattern : go to the pattern
          : n|N
:?pattern :
SHIFT + * : match the word marked cursor
:number_line : go to the number line

# ----- replace -----------------------
:r|R          : replace
:%s/x/y/g     : x change to y all of them
:s/x/y/g      : x change to y on the current line
:10,23s/x/y/g : 

# ----- special operation ------------------
:sp       : splite horizontally ; put some files into one terminal
CRTL + WW : change file in splite command
:ZZ|q     : quit a splite file

:set diff : compare two files
:vsp      : visual splite vertically
CRTL + WW : 

CRTL + V  : visual mode
          : d|D , y|Y, r|R
SHIFT + I : insert mode for editing
ESC       : Mactch visual mode
          
gf        : go into file
CRTL + O  : return the original file 

# ------ other command -------------------
J        : Merge the under line and the current line eg. 3JA
~        : change case-sensitive character 

linux常用命令

# ------ generic symbol ------------------------------------------
/           		: root directory
~          	 	: usr directory
./         		: current directory path
..         	 	: up directory path
!cmd       	 	: invoke last command
&          	 	: run job in background

# ------ file operation -----------------------------------------
man cmd     : manual

ls          		: list the directory and files
ls -a      		: list all includes hidden directory and files
ls -l      		: format list  
ll -a       		: format list 

cd         		: change directory to the /home/user
cd ~       		: ~ means the /home/user directory

cd dir_path 	: go to the dir_path directory

pwd         		: present working directory

mkdir dir      	: create a directory
touch file     	: create a file
vi file       	    	: vi editor
gvim file       	: gvim editor
chmod 777 dir 	: change r/w/x property 

cat file   		: look at the file context on terminal
more file  		: view the file
less file  		: view the file like gvim or vi

cp -f file1 file2 	: copy file1 to file2
cp -r dir1 dir2   	: copy directory recursively

mv file1 dir|file2 	: move (or rename) file1 to file2

wc file    		: count lines words and characters
wc -w file	 	: count word of file
wc -l file 		: count line  

rm file     		: remove file
rm -r dir   		: remove dir* (recursive)
rm -f file  		: enforced to remove file (force)
rm -rf dir  	: enforced to remove dir*

ln -s file link	: create a symbolic link to file

grep pattern file   	: search pattern matched in file
grep error sim.log  	:
grep -r pattern dir 	: search pattern incursively in directory

find / -name file_name 	: search the file from / directory
find /etc -name '*con*' 	:
find / -size +100M 		:

#------ pack files -------------------------------
tar -cvf file.tar files     	: create a tar file
tar -xvf file.tar           	: extract a tar file
tar -czvf file.tar.gz files 	: create a gzip file
tar -xzvf file.tar.gz
tar -cjvf file.tar.bz2 files	: create a bzip2 file
tar -xjvf file.tar.bz2

gzip file       	: create a file.gz file
gzip -d file.gz 	:

# ------ install rpm package ---------------------
rpm -qa           	: query all installed RPM packages
rpm -ivh RPM.rpm  	: install RPM package

./configure
make
make install

grep ERROR cmp.log > error.log
grep ERROR sim.log >> error.log
cat > file 		: sample the standard input and put them into the file

cmd | grep pattern  	: search pattern in cmd output
rpm -qa | grep vim
cat /etc/passwd | grep /bin/bash | wc -l
man ls | col -b > ls_man.txt
grep ERROR sim.log | tee -a error.log

#------ process manage -------------------------
ps          	 	: display the current active process
top          		: display all process of the OS
kill pid     		: stop the pid process
killall proc 	: stop all of the proc process
bg           		: list the suspended job in background
fg           		: resume the last suspended job in foreground

#------ system info ----------------------------
date          	: display system time 
date +%Y%m%d 	
date +%s      
date +%N

cal           		: display calendar
uptime        	: 
w             		: display who logon and what are doing
whoami 		: print effective userid
uname -a      	: display all OS system info

which cmd     	: show the full path of the cmd
su root|usr   	: change the usr
exit          		: usr shell quit
echo $PATH    	: show the variable
clear         	: clear the info on the terminal 
history       	: show the command history
!cmd          	: invoke the last cmd
make          	: invoke Makefile
make clean; make cpl; make sim  :

cat /proc/cpuinfo 	: show CUP information
cat /proc/meminfo 	: show memory information

df : report file system disk space usage
du -b|k|m file|dir	: estimate file space usage
du -s file|dir    	: summary
du -sm file|dir   

# ------ network info --------------------------
ping host|IP   	: ping IP address and print the result
hostname      	: display system host name
ifconfig -a   	: configure the network

# ------ hot key -------------------------------
ctrl + c  		: stop the current command
ctrl + z  		: suspend the job and put it into background
            'fg' can be used to resume the job
            free the license and take it soon
 
# ------ added by qixin gongzuoshi -------------
ctrl + d  		: display directoy in cd command

  • 5
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
GVim 是一个功能强大的文本编辑器,可以在终端中使用。下面是一些常用的 GVim 命令: 1. 打开文件: 在 GVim 中,你可以通过在终端输入 `gvim 文件名` 来打开一个文件。例如,`gvim test.txt` 将打开一个名为 test.txt 的文件。 2. 复制和粘贴: 在 GVim 中,你可以使用 `yy` 命令来复制当前行,并使用 `p` 命令来粘贴在光标位置。例如,将光标放在想要复制的行上,然后按下 `yy`,接着将光标移动到希望粘贴的位置上,然后按下 `p` 来粘贴。 3. 保存和退出: 在 GVim 中,使用 `:w` 命令可以保存当前文件,使用 `:q` 命令可以退出 GVim。如果你在进行编辑时没有保存文件,GVim 会警告你保存文件。如果你想同时保存并退出,可以使用命令 `:wq`。 4. 搜索和替换: 在 GVim 中,你可以使用 `/关键词` 来搜索当前文件中的关键词。例如,如果你想搜索文件中的 "hello",只需在命令行中输入 `/hello`,按下 Enter 即可。你还可以使用 `:s/旧关键词/新关键词/g` 来替换文件中的内容。 5. 跳转和移动: 在 GVim 中,可以使用 `gg` 命令来跳转到文件的开头,使用 `G` 命令跳转到文件的结尾,使用 `:行号` 命令跳转到特定行。还可以使用 hjkl 键来在文件中上下左右移动光标。 6. 撤销和重做: 在 GVim 中,使用 `u` 命令可以撤销最后的操作,使用 `Ctrl + r` 命令可以重做。 这些是一些 GVim 常用的命令,希望对你有帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值