vim

TAB not working when changing CTRL+S to save file in vim

早过忘川 提交于 2020-01-07 02:31:11
问题 I tried to save a file in vim by using CTRL + S . I came across this link http://vim.wikia.com/wiki/Map_Ctrl-S_to_save_current_or_new_files and according to it added these pieces of codes in .basrc and vimrc respectively: vim() { local STTYOPTS="$(stty --save)" stty stop '' -ixoff command vim "$@" stty "$STTYOPTS" } and nmap <C-s> :wq!<cr> Ok now CTRL + S saves the file. But TAB doesn't work now in insert mode. When I press TAB , cursor returns to first column of current line!! Any solutions?

How to remove line numbers in vim?

对着背影说爱祢 提交于 2020-01-07 01:52:27
问题 I have set line numbers in vim using :%!cat -n as suggested here. The line numbers appeard but now when I open vim I am getting 'E481: No range allowed:' errors and now I want to get rid of the line numbers. But how? 回答1: First, you can try this to get the line numbers: :%!cat -n % If you've not saved, you can revert back to the last save: :e! If you have the line numbers, then you can get rid of them like this :%s/^[[:blank:]]*[0-9]*\t// 来源: https://stackoverflow.com/questions/36579720/how

How to remove line numbers in vim?

坚强是说给别人听的谎言 提交于 2020-01-07 01:50:06
问题 I have set line numbers in vim using :%!cat -n as suggested here. The line numbers appeard but now when I open vim I am getting 'E481: No range allowed:' errors and now I want to get rid of the line numbers. But how? 回答1: First, you can try this to get the line numbers: :%!cat -n % If you've not saved, you can revert back to the last save: :e! If you have the line numbers, then you can get rid of them like this :%s/^[[:blank:]]*[0-9]*\t// 来源: https://stackoverflow.com/questions/36579720/how

Vim line numbers, absolute within visual mode and relative within insert

天大地大妈咪最大 提交于 2020-01-06 14:26:11
问题 I have line numbers set within my .vimrc. I'm wanting to switch to relativenumbers when in insert mode, and switch back to regular numbers in visual mode. I've tried: autocmd InsertEnter * :set number autocmd InsertLeave * :set relativenumber But this isn't working. I'm using Vim7.4.52 in terminal, Ubuntu. If possible I want to do this automatically, so I haven't got to fiddle with manually entering a command. 回答1: number and relativenumber setting are not exclusive anymore, so rather use

Vim copy one line and paste it to multiple lines [closed]

孤者浪人 提交于 2020-01-06 14:17:15
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I was sure I knew how to do it but I tried on different machines and it seems I don't know. 1 COPY THIS 2 3 4 HERE 5 HERE So that it becomes 1 COPY THIS 2 3 4 COPY THIS 5 COPY THIS What I tried: Shift-V on line 1 to copy line in visual mode, then go to line 4 visual mode vertical selection on lines 4 and 5. Now p

Open VIM with Java application

*爱你&永不变心* 提交于 2020-01-06 07:17:14
问题 I need my Java console application to do the following: Open VIM < the user input multiple lines of words and :wq > My application should then be able to get the vim input and print it in the terminal. So far I'm stuck at 1.. It seems impossible to get Java to open VIM! Here is some non functional code I have been fiddling with: call system text editor http://www.linglom.com/2007/06/06/how-to-run-command-line-or-execute-external-application-from-java Advice much appreciated EDIT Ok so the

Vim Surround + Repeat, wraps my text with ^M

独自空忆成欢 提交于 2020-01-06 07:07:35
问题 I'm using Vim's surround and repeat plugins to wrap lines of text with html tags. I'll use "yse<p>" and "ys$<p>", they both work fine. I try to repeat the command with ".", and it shows <p> in the terminal, but whenever I press enter to execute the command, surround replaces what should be <p> and </p> with ^M. My line looks like ^Mtext here^M I recognize the character as a line ending, but I don't understand why surround won't wrap my line with the code it shows in the terminal (which is

set nofoldenable not working in my vim - why?

帅比萌擦擦* 提交于 2020-01-06 04:03:28
问题 Every time I open one of my markdown ( .md extension) files in my MacVim, they automatically fold lots of lines, which is a pathetically frustrating feature in almost all cases. And even after I added set nofoldenable in my ~/.vimrc , it doesn't disable the feature at all. Writing in ~/.gvimrc doesn't work, either. So is it feasible to disable it? And what am I missing? I also wonder why the depressing folding feature only functions in my markdown files. As far as I know, all the other

Autoclose xml tags in C/C++ file in vim

亡梦爱人 提交于 2020-01-06 03:55:07
问题 I have some documentation strings embedded within the source code (C/C++ files) as XML tags and I'd like to know what's the most minimal solution to make vim autoclose the tags (closest matching tag). I've found closetag.vim but is there away to do this neatly without modifying anything but the .vimrc file? 回答1: Vim has no built-in support for that, so the closetag.vim plugin is the proper and easiest solution. (I use it myself, too!) Of course, you can develop your own simple mappings (that

How to add space between parenthesis and quotes on save

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-06 03:08:25
问题 I would like to add have VIM automatically add space between parenthesis and " / ' to match jquery style guidelines: http://contribute.jquery.org/style-guide/js/. This could be on save or by triggering a custom command. Ideally it would also add spaces before variable names but not functions or objects literal. What would be the best way to go about this? 回答1: To insert spaces on saves, use an autocommand : au BufWrite *.js silent! %s/\m(\@<=["']/ \0/g | silent! %s/\m["'])\@=/\0 /g au