vim

Insert text into current buffer from function

≡放荡痞女 提交于 2021-01-03 16:08:32
问题 I'm having a hard time finding the documentation for this. How do I read/write text from the current buffer in my vim functions? More concretely, if my buffer contains the words foo bar how would write a function to overwrite the word bar with cat so that in the end my buffer contains foo cat ? 回答1: You can use the substitute ex command inside a function. For example function! ReplaceBar() :%s/bar/cat/g endfunction This defines a function. The % character means operate on the entire buffer.

How to recursively grep the pattern inside the directory?

ε祈祈猫儿з 提交于 2021-01-03 08:45:41
问题 I would like to grep all string patterns which are start with the: student_ , then any numbers of symbols(letters and digits) and end with the .tcl 回答1: grep "student_[[:alnum:]]*\.tcl" * 回答2: If you're using vim 7, it comes with a build in grep function that puts the result in a quicklist-window. try :vimgrep /^student_/ **/*.tcl ** makes the search recursivelly To search in current directory only, use: :vimgrep /^student_/ *.tcl read more @ vim.wikia.com 来源: https://stackoverflow.com

The “git” command requires the command line developer tools. Would you like to install?

主宰稳场 提交于 2021-01-01 08:33:13
问题 I'm super new to coding (actually trying to teach myself some Python), but there's a thing bugging me that I cannot seem to find any info online about my particular case: When I run git on the terminal, there is: The "git" command requires the command line developer tools. Would you like to install.." Now, since I have a very basic Macbook 12, I try to keep it as lightweight and uncluttered as possible, so I don't want to install any IDE or anything, I'm practising coding with vim 7.3, but in

Custom syntax coloring vim

筅森魡賤 提交于 2021-01-01 04:54:16
问题 In vim can you call a theme for example, 'colo:desert' and colorize certain syntax which are not colorized like lets say i wanted to colorize the words "Access Validation" and "Panel" to green will Vim let met do that? Below is my desert theme which i use to colorize my syntax " cool help screens " :he group-name " :he highlight-groups " :he cterm-colors set background=dark if version > 580 " no guarantees for version 5.8 and below, but this makes it stop " complaining hi clear if exists(

Vim - delete until (inclusive) character in multiple lines

▼魔方 西西 提交于 2020-12-29 09:06:24
问题 I have this code: def foo(c: Char) = c match { case 'a': 'B' } My cursor is on the space after = . I want to delete everything until, including, the } . How can I do that? Can I do the same where the cursor is anywhere on the first line? Anywhere in the block (and place the cursor after the = )? 回答1: d/}/e does the job. d/} deletes until the } but adding the /e flag moves the cursor on the last char of the match, effectively deleting everything between the cursor and the } , inclusive . Using

Vim - delete until (inclusive) character in multiple lines

一个人想着一个人 提交于 2020-12-29 09:04:32
问题 I have this code: def foo(c: Char) = c match { case 'a': 'B' } My cursor is on the space after = . I want to delete everything until, including, the } . How can I do that? Can I do the same where the cursor is anywhere on the first line? Anywhere in the block (and place the cursor after the = )? 回答1: d/}/e does the job. d/} deletes until the } but adding the /e flag moves the cursor on the last char of the match, effectively deleting everything between the cursor and the } , inclusive . Using

Vim - delete until (inclusive) character in multiple lines

笑着哭i 提交于 2020-12-29 09:03:56
问题 I have this code: def foo(c: Char) = c match { case 'a': 'B' } My cursor is on the space after = . I want to delete everything until, including, the } . How can I do that? Can I do the same where the cursor is anywhere on the first line? Anywhere in the block (and place the cursor after the = )? 回答1: d/}/e does the job. d/} deletes until the } but adding the /e flag moves the cursor on the last char of the match, effectively deleting everything between the cursor and the } , inclusive . Using

How to expand a symbolic link to the full path of a filename in vim?

爷,独闯天下 提交于 2020-12-29 05:35:49
问题 I'm using a Mac and MacVim 7.3. I have a symbolic link ~/some/symlink which is a link to a real file ~/some/actual_file. When I "vim ~/some/symlink" it brings up the file in vim with vim's status line saying the name is ~/some/symlink, which makes sense. How do I get the full path of the "real" file ~/some/actual_file from within vim? I want the vim status line to say ~/some/actual_file instead of ~/some/symlink. I expected that the vim function resolve() would work, given its help

How to automatically change keyboard layout on switch to vim normal-mode?

微笑、不失礼 提交于 2020-12-29 05:30:25
问题 Sometimes I use vim to write non-US text, and when I wanna use any command in normal mode, I need to change layout to US. It's possible to do that automatically? PS. I can do mapping like this, but in this case command looks like :ц instead :w - not pretty and typo-risk. Update I don't want to use keymap option, because I prefer switch languages by CapsLock. I've try to write autocmd for InsertLeave event, but failed... Update 2 Probably anybody know, why the following not work? function

How to automatically change keyboard layout on switch to vim normal-mode?

可紊 提交于 2020-12-29 05:30:05
问题 Sometimes I use vim to write non-US text, and when I wanna use any command in normal mode, I need to change layout to US. It's possible to do that automatically? PS. I can do mapping like this, but in this case command looks like :ц instead :w - not pretty and typo-risk. Update I don't want to use keymap option, because I prefer switch languages by CapsLock. I've try to write autocmd for InsertLeave event, but failed... Update 2 Probably anybody know, why the following not work? function