Tag Info

New answers tagged

0

You can configure the .vimrc file as suggested here for using perl. filetype indent on " per-filetype config set tabstop=8 set expandtab set smarttab set shiftwidth=4 " or 2 or whatever set shiftround set autoindent Also you can download the perl plugin as well from here. The details on how to install the plugin can be found from here.


2

:h usr_01.txt and so on should do it for you.


2

To navigate to the section under the cursor, you use Ctrl] (that's a right bracket, not a j): JUMPING AROUND The text contains hyperlinks between the two parts, allowing you to quickly jump between the description of an editing task and a precise explanation of the commands and options used for it. Use these two commands: Press CTRL-] to jump ...


1

With my PatternsOnText plugin, you can restrict :substitute commands to pattern matches (\cite{...} in your case): :%SubstituteInSearch/\\cite{[^}]\+}/\(\d\+\)-\(\d\+\)/\=join(range(submatch(1),submatch(2)), ',')/g The regular expression parses the start and end numbers, and transforms them into the number range via join() and range(), using :help ...


1

First, that nnoremap <C-C> <silent> <C-C> has the <silent> parameter in the wrong position; it works, but not the way you think it does (and it beeps). Better use this: nnoremap <C-C> <Nop> To avoid the insertion of ^C when aborting r, define a special mapping for that, too: nnoremap r<C-c> <Nop>


2

To expand any single instance of a range of the form m-n within a \cite{...} expression, you could perhaps do something like perl -pe 's/\\cite{(?:\d+,)*\K(\d+)-(\d+)(?=(?:,\d+)*})/sprintf "%s", join(",", ($1..$2))/e' file.tex


3

You can use vim's substitute command to accomplish this: :%s/\\cite{1,3-7,9}/\\cite{1,3,4,5,6,7,9}/g This will replace all occurrences of \cite{1,3-7,9} with \cite{1,3,4,5,6,7,9}. To replace only occurrences that exist on the current line you can use: :s/\\cite{1,3-7,9}/\\cite{1,3,4,5,6,7,9}/g Append c if you want vim to ask for confirmation ...


0

The thing is that many of the more simple terminals only support the limited number of ANSI colours [Black | Red | Green | Yellow | Blue | Magenta | Cyan | White ] in regular or bold, 16 in total. The xterm-256color profile is supported by some of the more modern terminal emulators, such as gnome-terminal and PuTTY but 256 colors is still insufficient to ...


2

Actually, as is often the case with vim, if you can think of the feature, someone has probably implemented it. In this case, you are probably looking for the Colorizer plugin. Note that though this plugin “works best” with gvim, it supports 88 and 256 color terminals. From the script site: The idea is to highlight color names and codes in the same ...


0

For the specific file you can run the following while being in vim You will need to press Ctrl+V+I to create ^I. :%s /^I/^I^I^I^I/g


3

Add these lines to your .vimrc: set tabstop=4 set shiftwidth=4 set expandtab After that, each new tab character entered will be changed to 4 spaces, old tabs don't. You must type: :retab This will convert all existing tabs in files to spaces. If you don't want to use retab, you can use perl to replace each tab by 4 spaces: perl -i.bak -pe 's/\t/ ...


1

You seem to have a filetype plugin that installs a buffer-local mapping for Ctrl-C. You can check with :verbose imap <buffer> <C-c> It's probably the default one, cp. :help ft_sql. The prefix key can be reconfigured via this (in your ~/.vimrc): let g:ftplugin_sql_omni_key = '<C-j>'


1

Those messages come from evince. They are emitted when evince detected a PDF file change and it reloads the file. You can workaround this via redirecting stderr of evince to /dev/null. That means you can search for the evince call in the vim-latex plugin source and replace something like evince <OPTS> <INPUT> with: evince <OPTS> ...


1

awk '/\r$/ {sub(/\r$/, ""); printf "%s", $0; next} {print}' file


3

^M is a Windows-specific EOL (End Of Line) and it consists of two characters: carriage return \r and new line \n. So you must include \n in your replace command as well: %s/\r\n//g If you want to stick with you original replace command, then you must first convert EOL-format of your file from Windows one to Unix one. You can use dos2unix tool to do that: ...


1

You can do something like this in your .vimrc: highlight Test ctermfg=red autocmd BufWinEnter * match Test /Power/ autocmd InsertEnter * match Test /Power/ autocmd InsertLeave * match Test /Power/ autocmd BufWinLeave * call clearmatches() Then when you open file, any text matches Power will be highlighted as red. This is a static way, you can write your ...


2

Depending on exactly what you want, this is either what mark.vim or general syntax highlighting do. Mark allows creating some number of distinct groups of highlighted patterns or extents. Specifying a particular regular expression is done with Leaderr by default. There's also a :Mark command. You can set the colourscheme using :MarkPalette.


1

To match "something", but not after a specific "word", you can use \@<!; /\(word\)\@<! something/ For replacing "something" by "somethingelse", but only if "something" is not after "word": :%s/\(word\)\@<! something/ somethingelse/ From inside vim, show the description with :help /\@<!: \@<! Matches with zero width if the preceding ...


0

Instead of a % for a whole file replace, you could try with a range for the address: 0,/^References$/s/\s*\n*{\\&}\s*\n*/ /g 0,/^References$/s/\([A-Z]\)\.\([A-Z]\)\./\1\. \2\./g 0,/^References$/s/\(\w*\-\w*\|\w*\),\s*\n*\([A-Z]\)\./\r\\snm{\1}\r\2\./g (Assumes that References is the only word in the line. Modify the regex as needed.)


1

In bash with shopt -s extglob: for file in **/**; do [[ -f "$file" ]] && vim "$file"; done Note that, as per Stéphane's comment, prior to Bash 4.3 this would follow any symlinks in the directories covered.


5

With zsh: vim ./**/*(.) Other shells: find . \( -name '.?*' -prune \) -o -type f -exec vim {} + To open only the (non-hidden) regular files (not directories, symlinks, pipes, devices, doors, sockets...). vim ./**/*(D-.) Other shells, GNU find: find . -xtype f -exec vim {} + To also open hidden files (and traversing hidden directories) and ...


1

In addition to manually refreshing the file with :edit, you can put into your ~/.vimrc :set autoread to make Vim automatically refresh any unchanged files. Also see :checktime.


1

vipe uses temporary files (for me in /tmp) to pass and receive the pipe contents to / from Vim. Because of the pipeline, previous vipe invocations cannot be re-edited anymore; they've already been re-read by vipe and sent along the pipeline. So, it should be sufficient to save the previous vipe temp file (as the original one is removed by vipe), and re-open ...


2

You can use the :edit command, without specifying a file name, to reload the current file. If you have made modifications to the file, you can use :edit! to force the reload of the current file (you will lose your modifications).


4

You can use the last jump mark (m') as a temporary mark. To avoid using a different command to re-enter insert mode (i vs. a), you can use the gi command, which re-enters insert mode at the position where it was last exited: inoremap <F4> <Esc>m'ggVG=``zzgi


0

You can use i instead of a to keep the cursor at old position: inoremap <F4> <Esc>mqggVG=`qzzi I think you can't do better with q marker, from vim wiki: To set a mark, type m followed by a letter. For example, ma sets mark a at the current position (line and column). If you set mark a, any mark in the current file that was previously ...


3

You can turn that default behavior off via :set noequalalways You then have to explicitly make windows equal size (e.g. with <C-w>=) Alternatively, you can just turn this off for the window height via :set eadirection=hor


0

30 ctrl-w+ - increase window size by 30 lines 30 ctrl-w- - decrease window size by 30 lines


3

Try this (you'll need to install multitail): multitail -du -t "$(head -n 1 filename)" filename or, for headers longer than one line: multitail -wh 2 -l "head -n 2 filename" filename If you want to follow command output instead of a file: multitail -wh 2 -l "command | head -n 2" -l command or use -t as appropriate. Note that you may need to use ...


9

On terminals that support setting the scrolling region: tailf() ( # args: <file> [<number-of-header-lines>] trap 'tput csr 0 "$((LINES-1))"' INT tput csr "$((1+${2-1}))" "$((LINES-1))" tput clear { head -n"${2-1}" printf "%${COLUMNS}s\n" "" | tr ' ' = tail -n "$((LINES-1-${2-1}))" -f } < "$1" ) (assumes a shell like ...


0

Type Alt+L to return to command mode. It doesn't require any remapping or vim config change. It works because on most terminal emulators Alt+KEY sends an Esc followed by KEY (on xterm you might need to add a Xterm*metaSendsEscape: true line into your ~/.Xdefaults file). That behavior allows you to even "create" other insert mode combinations that work ...


1

vim --servername TAIL_VIM /tmp/somefile Now, in another shell (like bash), you can do: while true do inotifywait --event modify /tmp/somefile \ && vim --servername TAIL_VIM --remote-send '<C-\><C-N>:edit!<CR>G'; done Where the < C->< C-N> forces vim to go to normal mode, "edit!" tells ...



Top 50 recent answers are included