vi

How to run vi on docker container?

对着背影说爱祢 提交于 2019-12-03 07:21:05
问题 I have installed docker on my host virtual machine. And now want to create a file using vi . But it's showing me an error: bash: vi: command not found 回答1: login into container with the following command: docker exec -it <container> bash Then , run the following command . apt-get update apt-get install vim 回答2: Your container probably haven't installed it out of the box. Run apt-get install vim in the terminal and you should be ready to go. 回答3: The command to run depends on what base image

Executing VIM commands in a shell script

谁说胖子不能爱 提交于 2019-12-03 07:15:00
问题 I am writing a bash script that runs a command line program (Gromacs), saves the results, modifies the input files, and then loops through the process again. I am trying to use VIM to modify the input text files, but I have not been able to find a way to execute internal VIM commands like :1234, w, x, dd, ect. from the .sh file after opening my input files in VIM ("vim conf.gro"). Is there any practical way to execute VIM commands from the shell script? 回答1: I think vim -w/W and vim -s is

vi 的基本使用

做~自己de王妃 提交于 2019-12-03 06:34:52
vi 的基本使用 1.那么什么是vi呢? vi,Unix&Linux下最基本的编辑器,功能强大使用简单,是用户的必备利器。 2.它的模式有哪些呢? 1. 命令模式(默认,通过命令对文件内容进行编辑) vi //在当前目录创建空文件 vi filename //打开指定文件 vi -o|O f1 f2 //打开多个文件,o|O表示水平|垂直分隔 通过 vi打开文件后自动进入命令模式,此模式下所有输入都是命令 2. 插入模式(像windows中的普通编辑器一样使用) 命令模式下按 iaoIAO任一键进入插入模式,esc回到命令模式 i在光标前插入文本 I在光标所在行前插入 a在光标后插入文本 A在光标所在行未插入 o在光标所在行下插入新行 O在光标所在行上插入新行 3. 编辑模式(通过命令对文件或文件内容进行编辑) 命令模式下按 “:”进入编辑模式,esc或enter执行操作后回到命令模式 4. 视图模式(属于命令模式) vV进入视图模式,执行字符选中 例:按 "H"或"L"移动光标选中字符,通过yd进行复制剪切 3.然后就是它的常用命令: 1. 【定位命令】 hjkl:光标[左下上右]移动,同方向键 0:移至行首 ^:非空白行头 $:移至行尾 Enter:移至下行首 H:移至屏幕上端 M:移至屏幕中央 L:移至屏幕下端 C-F:下一页(C-F表示Ctrl+Shift+F) C-B

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

荒凉一梦 提交于 2019-12-03 05:40:53
问题 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? 回答1: 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

map jj to Esc in inputrc (readline)

孤街浪徒 提交于 2019-12-03 05:36:43
问题 How can I map jj to Esc in inputrc so it gets picked up by apps using GNU Readline (python, mongoshell, ...) all works fine on zsh using: bindkey -M viins 'jj' vi-cmd-mode this is my current inputrc: set editing-mode vi set keymap vi # turn off the stupid bell set bell-style none $if mode=vi set keymap vi-command "gg": beginning-of-history "G": end-of-history #"jj": vi-movement-mode set keymap vi-insert "\C-w": backward-kill-word "\C-p": history-search-backward $endif 回答1: You should

Swap text around equal sign

混江龙づ霸主 提交于 2019-12-03 05:15:53
问题 Is there an easy way to flip code around an equal sign in vi/vim? Eg: I want to turn this: value._1 = return_val.delta_clear_flags; value._2._1 = return_val.delta_inactive_time_ts.tv_sec; value._2._2 = return_val.delta_inactive_time_ts.tv_nsec; value._3 = return_val.delta_inactive_distance_km; (...) into this: return_val.delta_clear_flags = value._1; return_val.delta_inactive_time_ts.tv_sec = value._2._1; return_val.delta_inactive_time_ts.tv_nsec = value._2._2; return_val.delta_inactive

How do you open a file from within Vim?

血红的双手。 提交于 2019-12-03 04:34:57
I know how to open a file in vim from a terminal command line ( vim fileName ). What I can't figure out is how to open a file when I'm already within Vim. I tried :r fileName , but that appears to read (or append) the file into the unsaved buffer I have open. It creates a new file, because when I try to write it with :w , it asks for a filename. :e <filename> or :Ex <directory> lets you browse for the file from the given directory. :Ex on its own will open the pwd. :enew will create an empty buffer. this vim command you won't forget: :Sex if you want to point to certain dir, then :Sex <dir>

zsh vi mode status line

孤街浪徒 提交于 2019-12-03 03:43:51
问题 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? 回答1: 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

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

不打扰是莪最后的温柔 提交于 2019-12-03 03:41:31
问题 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

Unix script to remove the first line of a CSV file

烈酒焚心 提交于 2019-12-03 03:37:19
问题 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