Tag Info

New answers tagged

0

After searching through Steve Oualline's Vim book (New Riders Publishing, 2001), I realized what the answer was. The "wrong style" includes a stray extra exclamation mark near the end. <!-- Right style --> <!-- Wrong style --!> Why didn't I notice the extra mark the first time I read the help text? I guess I must have been reading it too ...


0

If some extra keystrokes do not bother you, I can‘t see a problem. GNU Screen’s copy-paste register (.) can be read from / written to file out of a box: <C-a>< and <C-a>> are default hotkeys, /tmp/screen-exchange is a default file, but I’d prefer a user-specific rather than system-wide so would set something like this in the .screenrc: ...


0

This is a very simple way to open files in terminal vim from iterm command click. It also jumps to the line number if it is specified. You will need to download one of the nightly builds to get the coprocess feature. Click on: Preferences -> Profiles -> Advanced Under "Semantic History", choose "Run coprocess..". In the text field, put: echo vim \1 +\2 ...


-1

Edit your \bin\vim file and comment out its contents, because erasing it is a pain to do without a true Linux environment. Go to your Windows 8.1 Control Panel and search for 'path'. The result of "Edit environment variables for your account" will show up, click it. Add the path to your VIM installation to the end of the PATH statement. ie ;C:\Program Files ...


0

For opening Windows Explorer showing current file's directory : :!start explorer /select,%:p (Source : http://vim.wikia.com/wiki/Open_Windows_Explorer_showing_directory_of_current_buffer )


2

I have no idea why you would want to do that (and your question has a strong XY problem smell to it) but you could reverse your text, do a normal substitution and revert your text back to its original order: :g/^/m0 :%s/search/replace/g :g/^/m0


3

You can't use a normal command on the command-line as is. In :g/^ /-1j, j is the abbreviation of :join: you go up one line (-1, it could be -) and you execute :join. In :g/^ /-1J, J means nothing to Vim: you are using a normal mode command out of its context so, basically, it does nothing after -1 except echoing a clear error message. Vim expects an Ex ...


1

There are two types of commands in vi. There are the commands that can be invoked directly from command-mode anywhere in the file (I'm not sure if there's a specific name for these kinds of commands), and there are commands that come from ex that specifically operate on lines (not on characters) and require a : character to invoke them. Typically, only the ...


0

How about using the built-in "cursorline" and "cursorcolumn" options? Then, you can use two autocmds: a BufEnter or WinEnter autocmd to do setlocal cursorline cursorcolumn and a CursorHold,WinLeave autocmd to do setlocal nocursorline nocursorcolumn.


2

What do you expect <C-x> to do? Vim is not nano. First let's solve your immediate issue: Hit <Esc> to get out of "^X mode". Hit <Esc> to get out of insert mode. Assuming you have the right privileges, type :wq to write the file and quit. Second, Vim is not at all like nano, it's a modal editor. The normal mode is the mode you are in ...


0

Set winheight=5 Set winminheight=5 Set winheight=999 If winheight is set too big before setting winminheight it will break the desired output. Setting an arbitrary low value fixed my problem.


1

An alternative to your blocking sleep would be to only remove the highlighting on a following event. To do that, after the matchadd(), just define another (fire-once; i.e. one that deletes itself) autocmd that clears the highlighting, and return from the function. Suitable events would be WinLeave,CursorMoved,CursorMovedI,CursorHold,CursorHoldI.


1

You can do this with the -s command-line option: vim -s cmd.txt 1.txt However, Teun Vink's comment is still valid. What are you actually trying to do? This sounds like the classic X->Y problem.


1

10|v9l (without the colon) moves the cursor to column 10, enters visual mode and expands the selection 9 characters to the right, ready to yank.


0

While marks will be adjusted for added / removed lines, the column position won't; you are correct in that. Your desired behavior certainly has multiple benefits; I guess it just hasn't been implemented yet, probably because of the complexity involved. (And it would break compatibility with vi and previous Vim versions, something which isn't taken lightly.) ...


0

To keep 4 lines in non-active windows: :set winminheight=4 To always maximize the current window to a height of 79: :autocmd WinEnter * setlocal winheight=79 You can also supply a higher number (999) to give it the maximum possible. This is called Rolodex mode. Unfortunately, the two cannot be easily combined.


1

Traditionally in unix environments, mounting home folders over nfs has typically been done and does what you describe, but is not the best option today for both performance reasons and portability of laptops. If you're looking to sync just dot files you may find using 'git' over ssh a bit easier and less problematic. It works well to sync changes and will ...


1

Though it is not a good idea to commit changes immediately after editing and quitting the file, you can try vim auto commands. augroup autocom autocmd! "executes the command on quit autocmd VimLeave *.cpp !your_command "execute the command on write autocmd BufWritePost,FileWritePost *.cpp !your_commad augroup END


2

You can mount remote machine's filesystem using sshfs, and then just make link using ln.


1

I will suppose that each of your key:value pairs is on its own line, like so: var myObject = { key1:val1, key2:val2, }; Then the following 2 regex/substitutions accomplish what you need: :%s/\(.*\):/'\1':/ followed by %s/''/'/ The first one replaces all text that precedes a colon (that's the \(.*\): part) with the same text (but surrounded by quotes) and ...


0

:%s/^.\{-}:\s*\zs[^',]\+/'&' seems to do the trick: ^.\{-}:\s* matches everything before the value: ^ | .\{-}: | \s* ---------------+---------------------+-------------------- start of line | any character, | as much whitespace | as few as possible, | as possible | until the 1st colon | ...


1

You could use vim-dispatch plugin for asynchronous build (make). or if you simply want shell command result in a quickfix window you coud use in ex-mode: :cexpr system('ls -alh') | copen even better, add this to you .vimrc command -nargs=+ Run :cexpr system('<args>') | copen and run in ex-mode: :Run ls -alh


0

Your hunch is right: The dead keys are handled by the operating system outside of Vim, and Vim only sees the result. You could remap the ' command to a different key, but there are few unused ones left. In case you're mostly editing in Vim (and you probably should, as it is such a superior experience), you don't need the US International layout at all: Vim ...


2

In Vim, this problem can be broken down into two parts: Applying an edit to multiple files Repeating the same edit For 1., you're using the DirDo plugin; alternatives would be the built-in :argdo, :bufdo, etc. For 2., you can use any (combination of) Vim commands. The most powerful one is :substitute, using a :[range] to select the lines, and regular ...


2

Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or ...


1

The problem is that in a terminal, a Tab character is ^I (Control-I). This means that pressing control while pressing tab is not something the terminal even bothers to pass through to Vim.[1] It just sends a regular tab character. GVim can support this because it doesn't have to rely on the terminal to tell it what keys are being pressed in what ...


0

In MacVim, you need to unmap the Edit > Paste menu item in order to override the shortcut, then you can remap Cmd-V (D-v in MacVim parlance) to the appropriate command in each mode. I added this to my ~/.gvimrc and now everything works wonderfully: macmenu Edit.Paste key=<nop> noremap <D-v> "*P cnoremap <D-v> <C-r>* inoremap ...


5

I can see that your current path is ~, your user's home directory. You should have write permissions to that directory. Think of it another way - if you have read and write permissions to the directory, what's stopping you from copying the file, deleting the old one and renaming the new one with different permissions? This is exactly what vim does! If ...


11

Because Vim is a text editor and works with text codepoints, not bytes. There is more than just one translation happening – when opening a file, the editor must decode it from the byte encoding to an internal representation (usually Unicode); when saving back to a file, or when displaying its contents on the terminal, the editor must encode the text ...


12

Why is the Unicode code point being displayed and not the UTF-8 code value? Because you use ga: <”> 8221, Hex 201d, Octal 20035 instead of g8: e2 80 9d


0

You can set up xterm emulation in advanced preferences, at least in Terminal 2.4 (OS X 10.9.3). This enabled proper mouse support for me.


0

I had a similar problem and made the plugin https://github.com/Konfekt/FastFold that updates the folds in your currently edited buffer by your preferred foldmethod when saving the buffer, and keeps them as is otherwise (by keeping the foldmethod set to manual).


3

The :col abbreviation expands to :colder, not :colorscheme. Typing :col<Tab> or :help :col would have told you that. I'd generally recommend to use the full command names in .vimrc or plugins for clarity; the abbreviations are most useful when entering commands interactively. So, you have to investigate why the colorscheme doesn't work: Does it work ...


0

Did you notice that the plugin actually defines the style of that highlight group? hi default DbgBreakptLine term=reverse ctermfg=White ctermbg=Green guifg=#ffffff guibg=#00ff00 Since it is sourced after your ~/.vimrc and your colorscheme it will override any rule with the same name. That's not very clean, unfortunately, so you basically have three ...


1

Never do anything in /etc/vim Because Vim follows a strict loading order and messing with the default files and directories will make Vim unstable. Some of the things you may do may work, others may not… it's only you and your luck. Because subsequent upgrades will overwrite some or all of your changes, making them pointless. Because it is customary and ...


0

Or.. you could think about doing it this way: nmap <D-F> :Ack <space> You don't need to mention the shift & this still only triggers with a capital F (so although shift isn't mentioned in the binding, you still have to press it). This works for me at least.


0

There seems to be some different approachs, depending on your current problem: Readonly by vi. If you file has :set readonly you can Use :w! to force write, or Issue :set noreadonly and then just use normal :w A permission problem (sudo): you can't write but you have sudo rights. Issue: :w !sudo tee %. This will write the buffer to tee, a command that ...


3

It sounds like you are going into select mode instead of visual mode. When select mode is active typing anything "printable" removes the selected text, enters insert mode, and inserts the character(s) you typed. You need to check the value of the 'selectmode' option and what file set it by running this command, including the question mark as part of the ...


0

This moves the help window once. So you can freely move it around after the window is created. if has('autocmd') function! ILikeHelpToTheRight() if !exists('w:help_is_moved') || w:help_is_moved != "right" wincmd L let w:help_is_moved = "right" endif endfunction augroup HelpPages autocmd FileType help nested call ...


0

With Vim, you can run :mksession to save your current session, i.e., mappings, options, variables, current directory, tabs, windows (and their layouts), etc. This saves all the session information into a file in the current directory called Session.vim (you can provide a filename to the :mksession command if you want to save different sessions in different ...


2

As described elsewhere, you can use this vim script to conceal the escape codes and format the text via syntax highlighting. Install it by downloading AnsiEsc.vba.gz version 12 from the bottom of the linked page, ungzip, open it in vim, run :source % in command mode.


1

You're looking for the cd mapping. Type this inside the NERDTree sidebar, and the current directory will be changed to the current entry's. See :help NERDTree-cd.


2

Your external command won't be able to do anything with a buffer number, you'll need to pass it a file name as argument. You can use bufname() to get the buffer name of a specific buffer: :execute "!g++ " . bufname(2) See :help bufname(). Note that, due to different things (your path mainly but also your compiler's options), the buffer name may or may ...


0

An enhancement to the answer of mrucci: You can use wc on linux without having to save the file first by directing the :w command output as follows: :w !wc -m and you can map it to something as mentioned by mrucci.


0

If you are referring to C indenting, try this: :set cinoptions+=:0 See: :help 'cinoptions' :help cinoptions-values


2

I'm assuming you're asking about the UTF-8 "phonetic extensions" block? Vim doesn't have default digraphs for those characters, but you can still enter them by pressing control-v, u, [4 character hex code]. Additionally, you can create your own digraphs with the decimal version of the code. For example, this creates a digraph for superscript "a": :digraph ...


2

This seems to work. function! CustomComplete(type) set iskeyword+=- return a:type endfunction inoremap <expr> <C-B> CustomComplete("<C-N>") autocmd CompleteDone * set iskeyword-=- We use an expression mapping to run the function which sets iskeyword every time its run (doesn't seem to be a problem. I also didn't find a autocmd ...


1

Vim indentation options Vim mainly uses 3 settings as for the indenting size : tabstop, ts : when Vim encounters a tabulation in a file you're opening, it displays the tab as {ts} spaces (see tabstop help, or type :help tabstop in Vim). softtabstop, sts : when you're editing a file and press the tab key, Vim uses this setting to define the width of the ...


0

Don't use visual mode. Simply change the text in the parens to "", and then paste the deleted text in between. ci)""<Esc>P If you want to use visual mode, it works the same, you just drop the 'i)' part: c""<Esc>P (<Esc> means hit the escape key)


2

This is intended to answer the specific question that you asked. You state that you have visually selected some text and want to surround it with quotes. To do that, run: :s/\%V\(.*\)\%V/"\1"/ To break that into parts: : allows you to enter ex commands. s/old/new/ is the usual substitute command. \%V is an under-documented atom to mark the beginning of ...



Top 50 recent answers are included