vim

Copy and paste in vim via keyboard between different mac terminals?

梦想与她 提交于 2019-12-20 09:19:09
问题 Can anyone help me with this: I'm trying to figure out how to copy and paste text between 2 different instances of vim on different terminals (using iterm2 or mac terminal). I can do it using the mouse if I do ":set mouse=a" but I'd like to be able to do it using the keyboard. I've googled around and it says you can use the "* or "+ registers to copy/paste to/from the system clipboard, but when I type * or + in vim, the mac makes one of those sounds it makes when you can't do something. I've

How to source all vim files in directory

孤街醉人 提交于 2019-12-20 09:16:25
问题 I have split my .vimrc into several files and placed them into ~/vimfiles/vimrc.d/ . Currently I source each file in that directory using exact name: source ~/vimfiles/vimrc.d/file1.vim source ~/vimfiles/vimrc.d/file2.vim etc. How to make a loop thourgh all files in that directory so i could only have to do such loop in my .vimrc: for file in ~/vimfiles/vimrc.d/*.vim source file enfor 回答1: As mb14 has already said, if you put them in ~/.vim/plugin they will be sourced automatically. For

Vim goes whack with tmux

此生再无相见时 提交于 2019-12-20 09:06:45
问题 NERDTree goes whack in tmux session as in the picture. The same problem exists when windows are split. But now i am using powerline This time the Vim status goes whack(in the picture see the middle portion of the status line) in tmux. What is wrong? 回答1: I figured the solution after a long time, looking at a dotfile repo in github. It was just a single line of code that made the communication between Vim and Tmux smooth. In the .tmux.conf file, add this line set-window-option -g utf8 on 来源:

vim regex increment all numbers by 1

谁说胖子不能爱 提交于 2019-12-20 08:59:19
问题 I have a prepared statement in java that i am adding an argument to the front of. Long story short, I have to take a ton of set methods and increment their first argument by 1. I'd like a quick way to do a search and replace matching all numbers, and then increment them by one. 回答1: Figured it out. %s/\d\+/\=(submatch(0)+1)/g http://vim.wikia.com/wiki/Using_an_expression_in_substitute_command 回答2: The only regex you need to know is \d . :g/\d/exe "normal! \<C-A>" 回答3: I mis-interpreted the

Vim no end of line on last line or eof

核能气质少年 提交于 2019-12-20 08:58:14
问题 I am trying to setup vim to skip adding eol on last line or eof, i have tried this :set binary :set noeol :w which is not perfect cause binary override filetype for later use. Any other option to set this, i don't need newline on last line. 回答1: I wanted to add an answer that I think can be as useful. The selected answer always remove the EOL on files even if they had one to begin with. This may be the behavior that you want, it also may not be. In my opinion I want to preserve the EOL as I

Clear certain criteria from .viminfo file

本小妞迷上赌 提交于 2019-12-20 08:57:07
问题 How can I clear certain criteria from my .viminfo file? I want to clear the command line history, file marks, jumplist, etc. However , I want to keep the search string history. Is there any way to do this? 回答1: I can think of 3 ways to do this. 1. Automatically Run Vim, Type: :set viminfo='0,:0,<0,@0,f0 '0 means that marks will not be saved :0 means that command-line history will not be saved <0 means that registers will not be saved @0 means that input-line history will not be saved f0 means

VIM: available shortcuts?

[亡魂溺海] 提交于 2019-12-20 08:49:37
问题 I use many shortcuts for my work in vim. Other shortcuts are taken by plugins. Sometimes I would like to add a shortcut for a new command but note afterwards that the shortcut was already taken. Is there a way to see a list of all available shortcuts in VIM? (all ctrl-shift-alt shortcuts) 回答1: Type :help index to see the mappings (shortcuts as you name them) and commands defined by vim itself. Type :map to see the mappings defined by your vimrc and plugins. Type :verbose map to know where

Switch to last-active tab in VIM

吃可爱长大的小学妹 提交于 2019-12-20 08:47:03
问题 In Vim, is there a way to quickly toggle between the current tab and the last active tab? Sort of the way ' ' toggles between the current line and the last active line. Plugins / keyboard mappings / voodoo all acceptable. 回答1: Put this in your .vimrc: if !exists('g:lasttab') let g:lasttab = 1 endif nmap <Leader>tl :exe "tabn ".g:lasttab<CR> au TabLeave * let g:lasttab = tabpagenr() Then, in normal mode, type \tl to swap to the tab you viewed last. 回答2: Fix the potential issue when a tab is

What are some good plugins for developing Java in VIM?

余生颓废 提交于 2019-12-20 08:43:44
问题 I love vim, but not having things like IntelliSense/Code completion from Eclipse makes it pretty difficult. I know, I know, I should be able to look at method signatures and java docs for the API I am interested in using. I'd love to, but I'd like it to be accessible from my fingertips instead of having to browse the source tree manually or have a JDK reference handy. What plugins would make this easier? 回答1: I tried eclim for a while. It was pretty good, basically it uses eclipse in the

How can I override ~/.vim and ~/.vimrc paths (but no others) in vim?

♀尐吖头ヾ 提交于 2019-12-20 08:41:04
问题 Let's say I have a tarball of all my vim config - everything normally inside ~/.vim (plugins, autoload, colours, all that stuff), and a vimrc file. I extract this to a directory somewhere. So in the directory where I am ($PWD), there is a "vim" folder and a "vimrc" file. (note: this directory will be read-only, so vim shouldn't try to write into it). What command-line arguments or environment variables can I give to vim to ensure that all my plugins, syntax, etc is loaded as well as the vimrc