vim

VIM: Send visual block to external command

不打扰是莪最后的温柔 提交于 2020-06-14 08:35:50
问题 How do I send a visual block to an external command? I select my block using Ctrl-q and then press ! program_name but vim sends the entire lines rather than the selected text blocks. I'm using gvim in Windows 10. 回答1: Vim always send the whole line to external commands, but you can do that using the function of the answer of romainl in this question: Sending visual selection to external program without affecting the buffer Passing a non-linewise selection to an external program is done like

Vim: overloaded mapping for multiple modes

纵饮孤独 提交于 2020-06-11 20:07:18
问题 I use mappings to normal mode commands that I'd also like to work in insert mode. This can be done by adding <C-o> to insert mode mapping: nmap <C-Up> 10<Up> imap <C-Up> <C-o>10<Up> But this means repeating each mapping twice. To avoid repetition, I've tried to "overload" some other key, then use it for mode-specific part: " F12 selects prefix suitable for current mode nmap <F12> <Nop> imap <F12> <C-o> " single mapping relying on "overloaded" F12 map <C-Up> <F12>10<Up> For some reason, it

Move to end of the current word in Vim

爱⌒轻易说出口 提交于 2020-06-09 11:42:07
问题 Usually I use ea to append something to a word; however, this doesn't work if the cursor is already in the last position of the word. ea will cause the cursor to move to the end of the next word. I'm interested to know whether there is any hotkey for moving to the end of current word even if the cursor is already in the last position of the word. Thanks. 回答1: You can change the functionality of e if you desire. For example, you could put nnoremap e he in your ~/.vimrc. This maps e to he so

g++ fatal error no such file or directory

混江龙づ霸主 提交于 2020-06-09 07:02:10
问题 So I am using the gvim editor to program in C++, however when I open a .cpp file on the editor then type :!g++ -std=C++17 file.cpp -o file I get this error: See attached file below: C:\Windows\system32\cmd.exe /c(g++ -std=c++17 file.cpp - o file) g++: error: file.cpp: No such file or directory g++: fatal error: no input files compilation terminated Now is this related to vim, or to my command? Thanks in advance. 回答1: It seems that you're unfortunately using gcc-mingw that doesn't come with

inotify don't treat vim editting as a modification event

心不动则不痛 提交于 2020-06-08 11:54:55
问题 my example code below watches a file for being modified. let's say the file being wathched is foo.txt, and the binary name came out from the sample code is inotify. I did two test for the sample code. test1: 1) ./inotify foo.txt 2) echo "hello" > foo.txt then everything works fine,and " file modified " has been printed out. test2: 1) ./infity foo.txt 2) vim foo.txt 3) edit somehow and save,but don't quit vim the printed out line is unknown Mask 0x00008000 , checked out the inotify header file

inotify don't treat vim editting as a modification event

给你一囗甜甜゛ 提交于 2020-06-08 11:54:41
问题 my example code below watches a file for being modified. let's say the file being wathched is foo.txt, and the binary name came out from the sample code is inotify. I did two test for the sample code. test1: 1) ./inotify foo.txt 2) echo "hello" > foo.txt then everything works fine,and " file modified " has been printed out. test2: 1) ./infity foo.txt 2) vim foo.txt 3) edit somehow and save,but don't quit vim the printed out line is unknown Mask 0x00008000 , checked out the inotify header file

inotify don't treat vim editting as a modification event

心不动则不痛 提交于 2020-06-08 11:54:38
问题 my example code below watches a file for being modified. let's say the file being wathched is foo.txt, and the binary name came out from the sample code is inotify. I did two test for the sample code. test1: 1) ./inotify foo.txt 2) echo "hello" > foo.txt then everything works fine,and " file modified " has been printed out. test2: 1) ./infity foo.txt 2) vim foo.txt 3) edit somehow and save,but don't quit vim the printed out line is unknown Mask 0x00008000 , checked out the inotify header file

navigating filesystem in vim -> :find vs. :edit

做~自己de王妃 提交于 2020-05-27 03:55:07
问题 When opening files in Vim I almost always do something like this: :e subDir/**/file<ctrl-d> But in the docs and basically every StackOverflow/blog post I have read it seems that people use "find" the way I use "edit". What am I missing by using the edit command instead of the find command? 回答1: :edit is restricted by default to the working directory: if you need to edit a file that is not under your working directory you will have to provide its absolute path or a path relative to the working

How to find all occurrences of a variable in Vim?

…衆ロ難τιáo~ 提交于 2020-05-24 21:37:41
问题 In vim, how to I find all occurrences of a variable in files under a certain directory? I know vimgrep works sometimes, but it looks for text only and doesn't work if other classes have variables of the same name and I only want the variable under a specific class. What should I do? Or should I get an IDE instead? 回答1: Why would you want to use another IDE when you already have one? Vim is an IDE that is configurable and usable for different languages.. You could use cscope to build a

git rebase -i with gvim doesn't wait for me to save?

旧巷老猫 提交于 2020-05-24 04:40:31
问题 When using git rebase -i with core.editor=gvim, the message "Successfully rebased and updated refs/heads/master." appears immediately, before I actually save the file that allows me to pick/reword/squash... commits. And gvim pops up with a message that the file is no longer available. Is this a config issue on my end, or does setting core.editor to graphical vim just not work? 回答1: When gVim is running in GUI (as opposed to inside the terminal), they will typically launch themselves in the