vim

Can I transpose a file in Vim?

家住魔仙堡 提交于 2019-12-31 13:12:13
问题 I know I can use AWK but I am on a Windows box. I am making a function for others that may not have AWK. I also know I can write a C program but I would love not have to create maintain and compile something for a little Vim utility I am making. The original file might be THE DAY WAS LONG THE WAY WAS FAST and it would become TT HH EE DW AA YY WW AA SS LF OA NS GT UPDATE: Golf rules apply to selecting correct answer. UPDATE: Python fans should check out Mr. Duffy's answer below. 回答1: Here is a

How to list all the environment variables in Vim?

强颜欢笑 提交于 2019-12-31 13:07:49
问题 When Vim is started, it grabs many of the environment variables from the operating system (like PATH ) and it also sets it own environment variables (like MYVIMRC ). How do I list or view all the environment variables that Vim understands and their respective values from inside Vim? 回答1: In Vim script, there is no designed way of getting the list of currently defined environment variables. However, it is possible to exploit Vim command-line completion feature. Consider possible completions

Vim colorscheme change

岁酱吖の 提交于 2019-12-31 12:52:13
问题 I'm having difficulty getting my colorscheme to change. I've opened both ~/.vimrc and /usr/share/vim/vimrc and added: colorscheme desert ...and nothing. I noticed the color schemes are here: /usr/share/vim/vim72/colors/desert.vim (...along with a bunch or others) which seems like the wrong place so I: cp /usr/share/vim/vim72/colors/desert.vim ~/.vim/colors/ and still no go. 回答1: Custom colorschemes should go in ~/.vim/colors/, and adding the colorscheme line in your ~/.vimrc should work. So

gvim: Easy copying into system clipboard

白昼怎懂夜的黑 提交于 2019-12-31 11:42:28
问题 I am using gVim on Ubuntu 10.10. I want to copy (yank) text to the system clipboard, so that the copied text is available in other applications. This works with "+y . But I want to have it working with y . I have tried to map y to "+y but then yy doesn't work anymore (since it produces "+y"+y ). I have also tried :set clipboard=unnamed but this works only the other direction: Text in the system clipboard I can paste with p . 回答1: Did you try to map with this command: noremap y "+y ? This

vimrc make comments italic

浪尽此生 提交于 2019-12-31 10:01:10
问题 How do I change the ~/.vimrc to have the comments in my code italicized? In my ~/.vimrc file I have: highlight Comment ctermfg=blue that makes the comments blue. What do I need to do differently to make them italic? 回答1: highlight Comment cterm=italic gui=italic You'll need a font with an italic set and a terminal capable of displaying italics. Also, if you're using a color scheme other than the default, the above line should come after the color scheme is loaded in your ~/.vimrc so that the

open vim from within bash shell script

巧了我就是萌 提交于 2019-12-31 09:59:52
问题 I want bash shell that does the following open a file using vim write something into file save and exit the file bashpromt# cat mybash.sh echo "about to open a file" vim file.txt #I need to use vim application to open a file #now write something into file.txt #close the that file. echo "done." IS that possible? I found something like vim script , but not sure how to use it. Or something like "HERE" doc can be used for this ? EDIT: I need to verify that vim editor is working fine over our file

How to break a line in vim in normal mode?

做~自己de王妃 提交于 2019-12-31 09:09:33
问题 I would like to break a line (at the location of the cursor) in to two lines without leaving normal mode (entering insert or command-line mode). Is this possible? I currently get to the location I want and hit 'i' to enter insert mode, 'enter' to break the line in two, then 'esc' to return to normal mode. I am not trying to set a maximum line length or do any syntax or anything like that. I just want to break one line into two lines without leaving normal mode. 'J' joins the line the cursor

How do I remap escape when in Sublime Text vintage mode?

倖福魔咒の 提交于 2019-12-31 08:56:24
问题 I am a vim user who is moving to Sublime text and using Vintage mode. In my .vimrc I have the following line: imap jk <Esc> In vim, this allows me to escape out of insert mode without having to lunge for the escape key and keep my fingers on the home row. How do I do the same thing with Sublime Text Vintage mode? 回答1: "Vintage mode is implemented entirely via key bindings and the plugin API - feel free to browse through the Vintage package and see how it's put together. As an example, if you

Spaces as tabs and backspace behavior in Vim

烈酒焚心 提交于 2019-12-31 08:52:13
问题 In my .vimrc I have: set shiftwidth=4 set tabstop=4 set expandtab set to use 4 spaces instead of tab when I hit the Tab button. But when I hit backspace after a Tab, I need to backspace all 4 spaces. Is there a way to have it so when I go to backspace a "tab" it can delete all 4 spaces? 回答1: Try set softtabstop=4 回答2: You can try using ^T and ^D. :help i_CTRL-T :help i_CTRL-D These allow to insert or delete (more like backspace though) a number of spaces equal to shiftwidth. 回答3: I have the

An alternative to minibufexplorer (vim)?

心已入冬 提交于 2019-12-31 08:48:11
问题 minibufexplorer is a persistent buffer manager for vim that lives in its own window. It shows all the buffers you have open, with color indicators as to which are currently visible in windows and which have unsaved changes. It's a great plugin which I've been hooked on forever. And without the persistent buffer display I find that I now feel lost. The problem is, minibufexpl tends to get in the way of other window controls. As it is a normal vim window, it behaves like one, causing issues if