Tag Info

Hot answers tagged

15

Use the \c escape sequence: /foo\c See also: http://stackoverflow.com/questions/2287440/how-to-do-case-insensitive-search-in-vim


9

In vi or vim you can ignore case by :set ic, and all subsequent searches will consider the setting until you reset it by :set noic. In less there are options -i and -I to ignore case.


6

With a large enough value of 'undolevel', Vim should be able to undo the whole day's changes. If you quit Vim in between, you also need to enable persistent undo by setting the 'undofile' option. Vim captures not just a sequential list of commands for undo, but actually a tree of all changes. It also has several commands around undo (cp. :help ...


4

Copy the content to your document in vim as you do, presumably with the middle mouse button in X, using insert mode, but on separate lines. Then go to the first column of the first of the newly inserted lines and go into visual block mode CTRL+v where you can select the content. The only issue here could be different line lengths that sometimes make it hard ...


4

Vimscript is evaluated exactly like the Ex commands typed in the : command-line. There were no variables in ex, so there's no way to specify them. When typing a command interactively, you'd probably use <C-R>= to insert variable contents: :sleep <C-R>=timetowait<CR>m<CR> ... but in a script, :execute must be used. All the literal ...


4

I understand your question as your long lines being wrapped around and you can't easily see where the two lines for the comments start and end. There are various options: 1) activate line numbers with :set nu, or 2) prevent wrapping by :set nowrap. What is preferable depends on whether you want to see the whole lines without scrolling or not.


4

You are already re-logged in with the new ssh session that you set up. If you want to connect the old edit session to you newly logged in session you can try reptyr which "reparents a running program to a new terminal". If this disconnecting happens often there are multiple things you can do: set ServerAliveInterval and/or TCPKeepAlive in ...


4

Just match anything (.*) between the start and end patterns: /^start123.*321end$


3

With my UnconditionalPaste plugin, you can force the paste to be blockwise, which is what you want here. So instead of entering insert mode and pasting with the middle-mouse button (which I suppose you've done), use the "* register together with the plugin's gbp mapping.


3

The built-in spellfile.vim script will attempt to download missing spell files from http://ftp.vim.org/vim/runtime/spell. In general, spell checking is not supported for East Asian languages like Chinese and Japanese, because individual words are not separated by whitespace, so a different algorithm would be needed. You probably want to :set ...


3

First, let's look at what we see in the terminal: $ echo <(vim) /dev/fd/63 $ Vim: Warning: Output is not to a terminal Notice that you get a prompt back immediately, without waiting for the editor to terminate. Process substitution doesn't wait for the command to finish, it creates a pipe between the command and the shell. A name for that pipe is ...


2

Try :set mouse=a, should be what you're looking for. Edit: As a side note, when you try to scroll through the file (as in two-finger scroll on a touchpad, for example), the text may not highlight as you'd expect. However, if you click where you want to start, then simply drag the mouse down, then everything should highlight as the mouse moves and the page ...


2

As St├ęphane Chazelas pointed out by using the vim help with :h :m it states the following: :[range]m[ove] {address} *:m* *:mo* *:move* *E134* Move the lines given by [range] to below the line given by {address}. Therefore by moving line 1 below line 3 the result is as stated in the question. ...


2

Use :2match for the second one (see :help :2match for details and also note that :3match is used for matchparen plugin): autocmd FileType python highlight OverLength ctermbg=red ctermfg=white guibg=red autocmd FileType python match OverLength /\%80v.\+/ autocmd FileType python highlight ExtraWhitespace ctermbg=blue guibg=blue autocmd FileType python 2match ...


2

Yes you can, with capture groups. Basically, you wrap the parts of the pattern with \(...\) and reference that in the replacement part with \1 etc.: :%s/Uset\(\d\d\)-\(\d\)/USet\1\2 Since you only want to remove a single part of the pattern, a shorter option is restricting the actual match (but still asserting that the stuff around is also there) via \zs ...


2

There's nothing built-in, but you can implement such by overriding all yank commands to temporarily :set clipboard=unnamed. (I wouldn't do it the other way around because there are many more commands that implicitly delete, like c, s, x, d, ...) The mappings can be quite simple, like :nnoremap <silent> yy :<C-u>set ...


2

The command history is stored in the viminfo file (:help viminfo). Usually that is read on startup and written on exit, but you could explicitly persist and sync between Vim instances with a combination of :wviminfo and :rviminfo. Note that this will sync the entire information; i.e. also register contents, marks, buffer lists, etc.


2

If you have xclip (sudo apt-get install xclip or similar) you can access the system (i.e. Xorg) clipboard from the command line, using xclip -o. This way, you can !paste - <(xclip -o) or define a key mapping (for instance <LEADER>p) as: :map <LEADER>p .,$!paste - <(xclip -o)<NL> and use <LEADER>p to paste the current X ...


1

Starting gvim opens a new window, so the terminal window stays available for commands. For intermediate "shell escapes" I do :sh to get access to a shell session, and type <Ctrl>-D to exit it; no fg is needed, but a prompt is added in this case to the console shell. And with no X running I start two consoles, one where vim is running, and the other ...


1

For several years I've been using a script wrapper around vi that saves the files I'm editing. It does this at most once per day so that I don't end up with too many backup files. This is a simpler version of the script I use; perhaps it's useful for you too. Instead of running vi, you would run vib (vi with backup): vib() { local DATE=$(date ...


1

Check out :help 'showbreak': 'showbreak' 'sbr' string (default "") global The global means that there's no buffer- or window-local value. You have to either Work around this with a set of :autocmds that switch the option based on the entered buffer. However, if you have multiple buffers in split windows, the other ones will also ...


1

Editors can follow several strategies to save a file. The two major variants are to overwrite the existing file, or to write to a new file and move it in place. Writing to a new file and moving it in place has the nice property that at any point in time, reading from the file gives you a complete version of the file (one instant the old one, the next instant ...


1

Just undo your changed option values: 'list' is a boolean flag whose inverse is 'nolist'. With your messed up value of 'listchars', you can reset it to the default by appending & (cp. :help :set-default): :set nolist lcs& Just restarting Vim also works :-)


1

Commands like :copy and :move put the target below the line given by {address}. You can use an address of 0 to move to the first line. Some commands (like :put) also support a reversal of before / after via :put!


1

Without using mouse you can select lines in Vim. Get out of insert mode, hit one of the options below, and then move up or down a few lines. You should see the selected text highlighted. V - selects entire lines v - selects range of text ctrl-v - selects columns gv - reselect block After selecting the text, try d to delete, or y to ...


1

Since I do not know which x11vnc you are using (I have three different versions, there are others) this is a tutorial to troubleshoot this specific problem. First is to understand the clipboards involved. There are in most cases four of them involved. (More is possible if you use clipboard management tools.) X11 defines three clipboards: Primary, Secondary, ...


1

I have run into this problem a few times as well. I happened to be running the screen program on another computer I was logged in to via ssh. to fix the problem I detached my screen(s), ^a d, logged off of the machine, logged back in, and reattached screen -x. It may work without logging off of the machine, just by detaching and reattaching screen, I cannot ...


1

I had problem with vim arrow keys while trying vim inside windows8.1 using cygwin. The issue was, printing A/B/C/D while navigating with Arrow keys in insertion mode. The solution worked for me is: cp vimrc_example.vim ~/.vimrc Basically, above command copying 'vimrc_example.vim' file in to '/home//vimrc'



Only top voted, non community-wiki answers of a minimum length are eligible