vim

How to flip the lines of a visual selection in vim?

懵懂的女人 提交于 2019-12-21 07:03:32
问题 I want to take a visual selection and flip it so that the first line of the selection is on the bottom. From: <other_stuff> The wheels go round. <more_stuff> Visual select the sentnce and then flip: <other_stuff> round. go wheels The <more_stuff> Any idea how to do this simply. I would rather not have to instal a plugin to do it. 回答1: When you make a visual selection Vim automatically makes the bookmarks '< and '> at the start and end of the block respectively, so you can do what you want in

Confirm line delete

情到浓时终转凉″ 提交于 2019-12-21 06:59:37
问题 I have created a function to search all double lines in a file. I use the "line-number"g/.*/d to delete the line. However I would like to confirm if a line has to be deleted or not, like the s/..//gc command Is it possible to delete a certain line with the global or substitute command and confirm every action? 回答1: Why not try a substitute command instead of the delete command? "line-number"s/^.*$\n//c 回答2: If I wanted to delete lines in a file and confirm each one, I would: search for the

Vim: Align continous lines with spaces

天大地大妈咪最大 提交于 2019-12-21 06:36:10
问题 I would like to indent everything in vim with tabs, except a particular case. For example I have this c++ code(where <tab> is a tab character series and <s> is a space character series): <tab>if(true && <tab><s>true) <tab>{ <tab><tab>//code here <tab>} I would like after writing '&&' and press 'o' to jump on the next line and start writing to make vim put a tab and the number of spaces till '(' from the line before. Is it possible to define this coding style in vim? Thanks! 回答1: I think what

vim: Executing a list of editor commands

余生颓废 提交于 2019-12-21 05:37:17
问题 Is there a way in vim to give a list of editor commands? I want to execute a series of 'global' commands, and there is some pattern to the commands. So I would ideally like to generate the list of commands (using regex search & substitute), and then run them, instead of having to type in each command. Thanks! Gaurav 回答1: (Update: s/buffer/register/g) If you can yank all of the commands you want to run into a register, then execute the register ? http://www.bo.infn.it/alice/alice-doc/mll-doc

php autocomplete with vim

烂漫一生 提交于 2019-12-21 05:31:11
问题 i'm looking for an php autocomplete solution for vim. I already was at this thread: Vim PHP omni completion but it doesn't work for me. I generate the tags file with this bash script: #!/bin/bash exec ctags -V -f tags \ -h \".php\" -R \ --exclude=\"\.git\" \ --totals=yes \ --language-force=PHP \ --tag-relative=yes \ --PHP-kinds=+cfiv \ --regex-PHP='/(abstract)?\s+class\s+([^ ]+)/\2/c/' \ --regex-PHP='/(static|abstract|public|protected|private)\s+(final\s+)?function\s+(\&\s+)?([^ (]+)/\4/f/' \

php autocomplete with vim

二次信任 提交于 2019-12-21 05:31:01
问题 i'm looking for an php autocomplete solution for vim. I already was at this thread: Vim PHP omni completion but it doesn't work for me. I generate the tags file with this bash script: #!/bin/bash exec ctags -V -f tags \ -h \".php\" -R \ --exclude=\"\.git\" \ --totals=yes \ --language-force=PHP \ --tag-relative=yes \ --PHP-kinds=+cfiv \ --regex-PHP='/(abstract)?\s+class\s+([^ ]+)/\2/c/' \ --regex-PHP='/(static|abstract|public|protected|private)\s+(final\s+)?function\s+(\&\s+)?([^ (]+)/\4/f/' \

Syntax highlighting in terminal vim but not gVIM

假装没事ソ 提交于 2019-12-21 05:22:23
问题 I am currently using VIM in the terminal and have perfect syntax highlighting happening. But then when I try to use gvim no matter what type of file or how many times I type: ":syntax on" I don't get any syntax highlighting. Any ideas anyone? Thank you. Here is my .vimrc for those who are interested: " Turn on pathogen for all plug-ins installed after 9/13/2010 call pathogen#helptags() call pathogen#runtime_append_all_bundles() " My color theme for vim colors sorcerer " Disable line wrapping

cscope error when trying to use ctags in vim

£可爱£侵袭症+ 提交于 2019-12-21 05:18:51
问题 I have generated ctags for my projects: ctags -f /home/grae/tags --recurse --langmap=C++:.C.h.c.cpp.hpp.inl --languages=C++ --extra=+q --fields=+iaS --c++-kinds=+p --verbose framework/ modules/ /usr/include/ I then added the tags to .vimrc: set tags+=/home/grae/tags I also temporarily added the following (but have now removed): set csto=1 Now when I try Ctrl+] or g] I get the error: cstag: tag not found I shouldn't be using cscope so I'm not sure how this has happened. My current thoughts are

What is a quick way to edit a remote file on Linux?

倾然丶 夕夏残阳落幕 提交于 2019-12-21 05:17:20
问题 I have a remote file that I edit regularly. I would like to edit it with a quick, simple command that would work likely via SSH. At present, my workflow is to connect to the remote computer via SSH, open the file using an editor (say vim or nano), edit, save and then close the connection. I am aware that I can mount the remote computer filesystem using SSHFS or Nautilus capabilities, but I'm really looking for a single command to run in the terminal which shall open the file in an editor,

How do you enable word wrap in vim when printing

廉价感情. 提交于 2019-12-21 05:07:34
问题 I wanted to print a simple text document and make sure words wrap on word boundaries. I tried both set linebreak and set wrap but when printing, it just breaks on the right column in the middle of words. Is this possible for printing? 回答1: You are creating a text file without any built-in linebreaks so each paragraph is a single "line", even though with linebreak and wrap set, it looks like they are multiple lines). This is why printing breaks at fixed places. (According to http://www.vim.org