vim

How to make vim use the same environment as my login shell when running commands with “!”?

喜你入骨 提交于 2019-12-21 04:48:12
问题 I use !ls to execute bash command. But after i have configured something like source ~/.usr_profile in ~/.profile file, vim won't source this file as well. So when i want to execute a function declared in usr_profile , i have to run :!source ~/.usr_profile && my_command . When i using this once or twice, it's ok. But when use it frequently, the my vimrc becomes messy. Is there any better method to solve this problem.Thanks 回答1: Adding this line to your ~/.vimrc should solve your immediate

Is it possible to achieve the so-called “distraction free mode” in Vim?

雨燕双飞 提交于 2019-12-21 04:42:20
问题 Just curious, kinda like the "distraction free mode" of editors like sublime text, is it possible to centroid all the text to the middle of view field? It's always annoying to stare at the left-most end of the vim terminal in fullscreen mode with a widescreen monitor. 回答1: You could take a look at VimRoom: http://projects.mikewest.org/vimroom/ Alternatively, you could set Vim up to have two or more vertical windows on your widescreen and have the same buffer automatically "snake" between them

Vim 快速入门 【VIM72原带】

非 Y 不嫁゛ 提交于 2019-12-21 04:39:34
Vim 快速入门 【VIM72原带】 第一讲小结 1. 光标在屏幕文本中的移动既可以用箭头键,也可以使用 hjkl 字母键。 h (左移) j (下行) k (上行) l (右移) 2. 欲进入vim编辑器(从命令行提示符),请输入∶vim 文件名 <回车> 3. 欲退出vim编辑器,请输入以下命令放弃所有修改∶ <ESC> :q! <回车> 或者输入以下命令保存所有修改∶ <ESC> :wq <回车> 4. 在正常模式下删除光标所在位置的字符,请按∶ x 5. 在正常模式下要在光标所在位置开始插入文本,请按∶ i 输入必要文本 <ESC> 特别提示∶按下 <ESC> 键会带您回到正常模式或者取消一个不期望或者部分完成 的命令。 第二讲小结 1. 欲从当前光标删除至单字/单词末尾,请输入∶dw 2. 欲从当前光标删除至当前行末尾,请输入∶d$ 3. 欲删除整行,请输入∶dd 4. 在正常模式下一个命令的格式是∶ [number] command object 或者 command [number] object 其意是∶ number - 代表的是命令执行的次数 command - 代表要做的事情,比如 d 代表删除 object - 代表要操作的对象,比如 w 代表单字/单词,$ 代表到行末等等。 $ (to the end of line), etc. 5. 欲撤消以前的操作

Vim highlighting weird parts of FORTRAN

社会主义新天地 提交于 2019-12-21 04:34:10
问题 I am using VIM theme molokai, if that makes any difference. I have been learning FORTRAN lately and when I write a FORTRAN program using VIM, I have weird coloring depending on my whitespace. For instance, if I tab things over as is (no indenting) I have this purple highlight on only a portion of the word (sometimes it isn't there, notice the PRINTs and READs). If I tab it over it looks normal: I am new to VIM (not to mention FORTRAN) so I am not sure what's happening, I don't mind tabbing

In Vim, is there a way to copy the current line number into a buffer?

China☆狼群 提交于 2019-12-21 04:32:25
问题 When using gdb and Vim, often I want to stop on a particular line. Normally in Vim I copy-paste the line number showing on the rule area to the gdb session. It'd save me a lot of hassle if I could use something like "+<magic-incantation> to copy the line number of the current cursor position into the xclipboard buffer. Is this possible? 回答1: put this in your vimrc map ,n <Esc>:let @*=line(".")<CR> then using , n will copy the current line number into the clipboard 回答2: So the magic line is:

Yank words separated only by periods

百般思念 提交于 2019-12-21 04:31:32
问题 I have a line like this in a file <echo>The app vendor is... app.server.name</echo> With the cursor over the 'r' in 'server', how can I yank 'app.server.name' without going into visual mode, or without having to guess the number of words to yank. yiw will only yank the word inbetween the periods. 回答1: Byt< B (to get you to the beginning of the punctuated word) yt< (to yank forward, up to but excluding the "<"). 回答2: 1. Quick and dirty: include dots in 'word' matching :se iskeyword+=46 Now y i

Yank words separated only by periods

三世轮回 提交于 2019-12-21 04:31:14
问题 I have a line like this in a file <echo>The app vendor is... app.server.name</echo> With the cursor over the 'r' in 'server', how can I yank 'app.server.name' without going into visual mode, or without having to guess the number of words to yank. yiw will only yank the word inbetween the periods. 回答1: Byt< B (to get you to the beginning of the punctuated word) yt< (to yank forward, up to but excluding the "<"). 回答2: 1. Quick and dirty: include dots in 'word' matching :se iskeyword+=46 Now y i

Need to duplicate text in each line and add equal sign and prefix to it

可紊 提交于 2019-12-21 04:29:24
问题 This is my text: xxx yyy zzz I would like it to be this text instead: xxx = C.xxx yyy = C.yyy zzz = C.zzz Is this possible to do in Vim? 回答1: You can also use the simpler form: :%s/.*/& = C.& 回答2: Type this: :%s/\(.*\)/\1 = c.\1/g Breakdown: % - work on all lines \(.*\) - capture all the characters in a group ("group 1") s/PATTERN/REPLACEMENT/g - do a string substitution \1 in the replace pattern - refer to the matched group 回答3: Select the text, then press : and type s/\(.*\)/\1 = C.\1/ 来源:

Executing Bash functions from within Vim - how can I do it? [duplicate]

落爺英雄遲暮 提交于 2019-12-21 04:13:40
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Commands executed from vim are not recognizing bash command aliases I have the following function in my ~/.bashrc file (on my Ubunut box) # convert tex to pdf, no bib function t2p { latex $1 && latex $1 && dvips $1 -o $1.ps && ps2pdf $1.ps && rm -f $1.dvi } # convert tex to pdf, with bib function tb2p { latex $1 && bibtex $1 && latex $1 && latex $1 && dvips $1 -o $1.ps && ps2pdf $1.ps && rm -f $1.dvi } For

第十章 Vim程序编辑器学习

倖福魔咒の 提交于 2019-12-21 04:10:37
  1.Vim是进阶版的vi,vim不但可以用不同颜色显示文字内容,还能进行诸如shell script,C program等程序编辑功能。   区别:vi是老师的字处理器,不过功能已经很齐全,但还是有可以进步的地方。      vim则是一个“程序开发工具”而不是文字处理软件。在vi 的基础上加入了支持正则表达法的搜寻架构,多档案编辑、区块复制等等。 2、vi有一般模式,编辑模式、与指令列命令模式。 一般模式:可以用上下左右来移动光标,也可以使用“删除字符和删除整行”“复制和粘贴”来处理你的文件,但无法编辑文件。 编辑模式:在一般模式下,按下“i,I,o,O,a,A,r,R(取代)”等任何一个字母之后才会进入编辑模式。如果要回到一般模式,则按下“ESC”按键即可退出编辑模式。 指令列命令模式:在一般模式当中,键入“:/ ?”三个中任何一个按钮,就可将光标移动到最底下那一行。在这个模式当中,可以提供“搜寻资料、读取、存盘、大量取代字符、离开vi、显示行号”等动作 vi后面一定要加档名:vi test.txt.进入文档编辑模式 离开字符命令“:wq” ls -l:查看文件属性 一般模式下:h(向左)j(下)k(上)l(右)移动光标,如果想要进行多次移动的话,向下移动30行可使用“30j”或者"” "ctrl+f"="page down" "ctrl+b"="page up"