vi

Linux操作系统平台Vi指令大全

假装没事ソ 提交于 2019-12-02 18:25:36
/ 根目录下的文件夹 输入”/”,回车里面有很多文件夹,如:etc,home,lib,mnt等等etc:存放用户名和密码home:每个用户有个文件夹,存放在这里lib:操作系统文件等mnt:挂扣用的opt:java工具bea:web编程的一些东西sbin,bin,usr:这三个文件夹都是存放unix的命令的tmp:临时文件夹 常用的操作: 查看当前目录:pwd修改密码:passwd更换模式:csh,bash远程登陆:telnet 服务器ip回到上级目录:cd ..查看该目录下的文件夹:ls打开文件:vi /文件夹/文件文件显示的格式:root:x:0:root…:/root;/bin/bash 用户名,加密,序号,组,默认路径退出:esc shift+: q! quit exit清空:clear显示当前目录所有文件:ls –a显示当前目录所有文件和详细信息:ls –al新建文件:vi 文件名文件的权限:chmod g –(+)r w x u g o s 新建文件(不能编辑)更新文件的访问时间,如果存在文件,更新,不存在,建立:touch 文件名创建目录:mkdir 目录名/目录名创建多个目录:mkdir 目录名 目录名…..在主目录创建下目录:mkdir ~/目录名创建多级目录:mkdir –p 目录名/目录名在覆盖文件前做个提示:cp –I文件和文件内容间的拷贝:cp复制目录

Is there any way to enable code completion for Perl in vim?

北战南征 提交于 2019-12-02 18:07:42
Surprisingly as you get good at vim, you can code even faster than standard IDEs such as Eclipse. But one thing I really miss is code completion, especially for long variable names and functions. Is there any way to enable code completion for Perl in vim? Kris Erickson Ctrl - P (Get Previous Match) and Ctrl - N (Get Next Match) are kind of pseudo code completion. They basically search the file (Backwards for Ctrl - P , Forwards for Ctrl - N ) you are editing (and any open buffers, and if you are using TAGS anything in your TAG file) for words that start with what you are typing and add a drop

In Vim, what is the best way to select, delete, or comment out large portions of multi-screen text?

落爺英雄遲暮 提交于 2019-12-02 17:34:11
Selecting a large amount of text that extends over many screens in an IDE like Eclipse is fairly easy since you can use the mouse, but what is the best way to e.g. select and delete multiscreen blocks of text or write e.g. three large methods out to another file and then delete them for testing purposes in Vim when using it via putty/ssh where you cannot use the mouse? I can easily yank-to-the-end-of-line or yank-to-the-end-of-code-block but if the text extends over many screens, or has lots of blank lines in it, I feel like my hands are tied in Vim. Any solutions? And a related question: is

Opening files in the same folder as the current file, in vim

喜欢而已 提交于 2019-12-02 17:15:42
In vim, when I have a buffer open, I often need to load another file in the same directory that file is in, but since I don't usually cd into it, the pwd is a parent folder, so I have to retype the path every time. Is there a shortcut for this? or a way to change the pwd to the directory the file is in? example: cd /src vi lib/foo/file.js lib/foo has two files: file.js and file2.js in vi: :e file2.js # doesn't work Newer versions of vim have a autochdir command built in, if not you can fall back to a BufEnter like setup. " set vim to chdir for each file if exists('+autochdir') set autochdir

How to indent multiple lines starting from the middle in vi?

半世苍凉 提交于 2019-12-02 17:13:04
问题 For example, to convert this $example = array( 'First' => 'This, 'Second' => 'is', 'Third' => 'an', 'Fourth'=> 'example', 'Fifth' => '.', ); into this $example = array( 'First' => 'This', 'Second' => 'is', 'Third' => 'an', 'Fourth' => 'example', 'Fifth' => '.', ); without having to indent each => 'whatever', each time. Is this possible to do in vi? 回答1: There are two Vim plugins for that, Align and Tabular. With Align, select the lines and execute :'<,'>Align => Tabular is a more recent

Bash script calls vi for manual editing, then script resumes?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 17:10:45
问题 I wrote a script that creates a backup of a text file, and a second script that verifies some syntax in text file using SED. In the middle, there is a manual process: Users edit the original file adding some strings. This process must remain manual. I would like to merge my two scripts so the backup is created, vi is open for the user, when the user is done editing the file, the script resumes doing the syntax verification. I am learning by doing, but really do not know how to code the "open

zsh vi mode status line

独自空忆成欢 提交于 2019-12-02 15:58:52
Is there a way in zsh or bash to have a status line? e.g. in VI it will let you know that you are in insert mode with -- INSERT -- Is there an eqivalent for the command line? Gilles This has already been answered at Super User and Unix Stack Exchange . For the completeness of Stack Overflow: function zle-line-init zle-keymap-select { RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}" RPS2=$RPS1 zle reset-prompt } zle -N zle-line-init zle -N zle-keymap-select And if you want the indicator below the current line rather than to the right, from Unix Stack Exchange : terminfo_down_sc=

What is a way to read man pages in vim without using temporary files

半城伤御伤魂 提交于 2019-12-02 15:56:28
I want to be able to read man pages in vim. For some reason, it seems that vim isn't able to read the output of programs through piping (i.e '(man ls) | vi' doesn't seem to work, bonus points to somebody who can explain why), and to get around this, I've been using the following little script: tempo = `mktemp` man $1 > $tempo ; vi $tempo This script uses temporary files which I guess works fine, but I was wondering if there was a good way to read man pages in vim without resorting to making temporary files For some reason, it seems that vim isn't able to read the output of programs through

Unix script to remove the first line of a CSV file

旧城冷巷雨未停 提交于 2019-12-02 15:48:25
I've stated before I'm not very good at scripting so what I have below copies files from a share directory to mine where I change their permissions. But then I wanted to remove the first line in each of the CSV files — the headings — and then I wanted to get this to run every hour. cd /users scp dehpc14_Disk_Quota_Report.csv /h/u544835 scp dehpc14_User_Disk_Usage.csv /h/u544835 cd /h/u544835 chmod 755 dehpc14_Disk_Quota_Report.csv chmod 755 dehpc14_User_Disk_Usage.csv * insert delete csv first line here * Can anyone help me with deleting the first line of the CSV file and getting this to run

How can I delete multiple lines in vi?

烈酒焚心 提交于 2019-12-02 15:45:18
I have tried to follow the following: How to delete selected text in VI editor but 5dd gives E492: Not an editor command: 5dd I then tried: 5d Which only deletes a single line. How can I delete multiple lines? Sounds like you're entering the commands in command mode (aka. "Ex mode"). In that context :5d would remove line number 5, nothing else. For 5dd to work as intended -- that is, remove five consequent lines starting at the cursor -- enter it in normal mode and don't prefix the commands with : . KCD I find this easier Go VISUAL mode Shift + v Select lines d to delete https://superuser.com