vi

Linux vi arrow keys broken in insert mode

十年热恋 提交于 2019-12-17 08:06:52
问题 My arrow keys don't work in vi in insert mode at home, they just each insert a newline and a capital letter, like 'A'. Is there a way to fix that? 回答1: I presume you're using vim as this is tagged as Linux. Try: :set nocompatible (You may want to configure your .vimrc with this by adding this command to it. Create a new .vimrc file if not already present in your home directory, run echo $HOME to check home directory path.) 回答2: Ubuntu ships default with vim-tiny , which doesn't have all the

Linux vi arrow keys broken in insert mode

左心房为你撑大大i 提交于 2019-12-17 08:06:38
问题 My arrow keys don't work in vi in insert mode at home, they just each insert a newline and a capital letter, like 'A'. Is there a way to fix that? 回答1: I presume you're using vim as this is tagged as Linux. Try: :set nocompatible (You may want to configure your .vimrc with this by adding this command to it. Create a new .vimrc file if not already present in your home directory, run echo $HOME to check home directory path.) 回答2: Ubuntu ships default with vim-tiny , which doesn't have all the

How to paste over without overwriting register

筅森魡賤 提交于 2019-12-17 05:38:35
问题 Does anyone know of a way to paste over a visually selected area without having the selection placed in the default register? I know I can solve the problem by always pasting from an explicit register. But it's a pain in the neck to type " x p instead of just p 回答1: "{register}p won't work as you describe. It will replace the selection with the content of the register. You will have instead to do something like: " I haven't found how to hide this function (yet) function! RestoreRegister() let

Why do Vim experts prefer buffers over tabs?

為{幸葍}努か 提交于 2019-12-17 02:25:04
问题 I don't understand buffers. When I open 3 files on the same tab and close my window, I'm generally annoyed to find out next time I open one of those files that there are strange swap files lingering and giving me pesky messages. But time and time again I read that these things are the productivity nirvana I'm missing out on and that tabs were made for the plebeians to use. So I ask you, the Vim expert: what are the advantages of using buffers over tabs? I don't see how the difference could be

autocmd event to execute a command on :wq - vimscript?

☆樱花仙子☆ 提交于 2019-12-14 01:16:55
问题 I want to execute system("cp /home/currently_opened_file.txt /somewhere/else") when I exit vim with :wq . Is there an autocmd event for that? Or any other way to do it? 回答1: Update : The OP noted in comments that this combination did exactly what was wanted (execute the command only on :wq ). :autocmd BufWritePost * :autocmd VimLeave * :!cp % /somewhere/else Original answer : You can hook the BufWritePost event. This will run the command on every write, not only when you use :wq to leave the

Activation of `.vimrc` file

浪子不回头ぞ 提交于 2019-12-13 22:16:44
问题 I have got a .vimrc file from one of my friends, however, vim ignores it. How can I make vim use .vimrc ? Thank you for the answer. 回答1: Open vim and type ":version" and hit Enter. You will get paths to your vimrc files. Make sure that your vimrc file is not overwritten by another one (with a higher priority). Please refer to Open vimrc file. EDIT: To see a home directory, type in vim :echo $HOME 来源: https://stackoverflow.com/questions/39419595/activation-of-vimrc-file

Opening a Config file in a Vim editor while being used by a script

笑着哭i 提交于 2019-12-13 20:29:03
问题 I have a question about Vim. So i have a recipients.cfg config file, and it is being used by a script named check.sh that is sending some stats (send like an sms), and is running every minute via cron. If i Vim recipients.cfg and leave it open for like 10 minutes, will check.sh still be able to use the recipients.cfg and send the stats? Thank you! 回答1: Yes. Vim only creates hidden .swp files of the file you are editing, for recovery purposes, and also to lock other Vim sessions from writing

editing tomcat-users.xml in CentOS 7 linux

烂漫一生 提交于 2019-12-13 07:50:23
问题 I am trying to edit tomcat-users.xml in tomcat 8 , using the terminal of CentOS 7 linux . I typed su - to use the terminal as the root account. I then typed in vi $CATALINA_HOME/conf/tomcat-users.xml , but the result is that vi opens in the window with the contents of tomcat-users.xml in read-only mode, and there seems to be no way out of vi except to close the window, losing all the terminal history. I also navigated to the physical location of tomcat-users.xml and opened up the file using

vi mode to emacs mode while on R

北慕城南 提交于 2019-12-12 15:18:42
问题 Sometimes while on the R console I accidentally type an unknown keyboard short cut that changes the editing mode from emacs to vi. Does anyone know what is usually this combination of keys to change from one to the other? I am on a Fedora 16 machine I checked the info on this question but using meta+v or meta+e doesn't change anything. UPDATE: The keystrokes shown the answer below work ONLY WITHIN R ! 回答1: R uses the GNU readline library for keyboard editing modes. I think the answer is

Switching from tab to splitted window in vi/vim?

心已入冬 提交于 2019-12-12 14:42:51
问题 We can make new tab using :tabnew . We can split window using :vs or :sp . Sometimes I want to switch from tab to splitted window to compare my code or switch back to get more space. Now I do it by closing it then use another command. Is there any easier way? Thank you. 回答1: Tabs and splits are different concepts. A vim "tab" is really a window layout. It means that for example you can have a tab with vertically split windows and another one with horizontally split windows. It seems you