christianmlong + vim   185

GitHub - maxbrunsfeld/vim-yankstack: A lightweight implementation of emacs's kill-ring for vim
Yankstack.vim is a lightweight implementation of the Emacs 'kill ring' for Vim. It allows you to yank and delete things without worrying about losing the text that you yanked previously. It effectively turns your default register into a stack, and lets you cycle through the items in the stack after doing a paste.

This plugin is intended to be a simpler alternative to the yankring plugin. It has a fairly complete test suite based on rspec and vimbot.
paste  copy  history  plugin  vim  yank  killring  yankring 
march 2019 by christianmlong
vimrc - Opening a vertical terminal in Vim 8.1 - Unix & Linux Stack Exchange
:vert term

:vertical works with any command that splits a window, for example:

:vert copen
:vert help vert
vim  vertical  split  bash  terminal  window 
october 2018 by christianmlong
GitHub - tpope/vim-abolish: abolish.vim: easily search for, substitute, and abbreviate multiple variants of a word
Vim plugin to do case-smart substitutions, and to convert from snake_case to camelCase.

:%S/supplier/product/g will do SUPPLIER->PRODUCT and Supplier->Product in one go
vim  plugin  tpope  text  snake_case  camelCase 
august 2018 by christianmlong
Slow scrolling in vim due to cursorline and relativenumber
Slow scrolling in ruby files with syntax: on and set relativenumber
vi  vim  syntax  highlight  ruby  slow  performance  scroll  annoyance 
february 2018 by christianmlong
input: distinguish Tab and ctrl-i
Actual behaviour

C-i is synonymous to Tab
Expected behaviour

C-i is not synonymous to Tab
Steps to reproduce using nvim -u NORC

Input C-i

My limited understanding of vim's input system is that certain non-alpha control keys are handled as chorded alpha/modifier keys, Tab being one. Since I use an odd keyboard layout, I would very much like to bind some certain keys to make things behave, unfortunately this isn't really an option seeing as I can either lose the ability to input Tab or lose the ability to comfortably navigate in insert mode.

I propose that, inline with nvim's (continued) refactoring and redesign of vim internals that input such as Tab not be handled as chords and rather its own input.
vim  neovim  tab  ctrl-i  keybindings  terminal 
december 2017 by christianmlong
rhubarb.vim: GitHub extension for fugitive.vim

If fugitive.vim is the Git, rhubarb.vim is the Hub. Here's the full list of features:

Enables :Gbrowse from fugitive.vim to open GitHub URLs.

Sets up :Git to use hub if installed rather than git.

In commit messages, GitHub issues, issue URLs, and collaborators can be omni-completed (<C-X><C-O>, see :help compl-omni). This makes inserting those Closes #123 remarks slightly easier than copying and pasting from the browser.
git  vim  fugitive  rhubarb  github  hub  tpope  plugin 
august 2017 by christianmlong
keyboard shortcuts - Remap bash vi keys? - Unix & Linux Stack Exchange
set -o vi

You can create a file named '.inputrc' in your home directory.

# want vi to be the default editor for readline
set editing-mode vi

# vi settings
$if mode=vi
# normal mode
set keymap vi-command
"j": beginning-of-history
"l": backward-char
"h": forward-char
"G": end-of-history
# insert mode
set keymap vi-insert
"jj": vi-movement-mode # remap escape
vi  bash  readline  edting  mode  vim  set 
october 2016 by christianmlong
Vim delete HTML tag, but not content - Stack Overflow
With the surround.vim plugin, use dst (for delete surrounding tag). Same with ds(, ds" etc.
vim  surround  plugin  delete  surrounding  tag 
august 2016 by christianmlong
Vim binding for iPython notebooks
vim  vi  python  ipython  jupyter  key  binding 
august 2016 by christianmlong
jslint - How do you use vim's quickfix feature? - Stack Overflow
The easiest way to navigate the quickfix list (or the location list, for that matter) is the unimpaired plugin.

Once the quickfix window is populated, [q and ]q go forward and back (respectively) in the quickfix list. [Q and ]Q go to the beginning and end (which is especially handy if you only have one item in the list; this makes vim complain about [q and ]q). So the workflow is:

Run whatever command populates the quickfix list
Type [Q to go to the first item
Scroll through subsequent items (if any) with [q and ]q

If you're using Syntastic, you'll get the location list instead of the quickfix list. No problem; just use [L, ]L, [l, and ]l in the same way.

unimpaired has loads of other handy mappings too -- [e and ]e "bubble" lines up and down, [<Space> and ]<Space> insert blank lines above and below, etc
vim  unimpaired  plugin  quickfix  navigation 
june 2016 by christianmlong
How do I disable the "Press ENTER or type command to continue" prompt in Vim? - Stack Overflow
This is how I run external commands in tricky scenarios without having "Press ENTER". Unlike :silent, I can still see the command output.

Command line

:exe ":!<command>" | redraw

Script / function

exe ':!<command>'

Mapping with <expr>

map <expr> <F5> ":exe ':!<command>'\n:redraw\<CR>"

Mapping with <expr> that calls a function

map <expr> <F5> MyFoo()
fu! MyFoo()
return ":exe ':!<command>' | redraw\<CR>"
vim  silent  command  annoyances  enter  bash 
june 2016 by christianmlong
cmdline-mode enhancement for Vim
vim  plugin  cmdline-mode 
june 2016 by christianmlong
Peekaboo extends " and @ in normal mode and <CTRL-R> in insert mode so you can see the contents of the registers.

Using vim-plug:

Plug 'junegunn/vim-peekaboo'


Peekaboo will show you the contents of the registers on the sidebar when you hit " or @ in normal mode or <CTRL-R> in insert mode. The sidebar is automatically closed on subsequent key strokes.
vim  plugin  clipboard  register  view 
june 2016 by christianmlong
Simplified clipboard functionality for Vim.
EasyClip is a plugin for Vim which contains a collection of clipboard related functionality with the goal of making using the clipboard in Vim simpler and more intuitive without losing any of its power.

A good starting point for the motivation behind this Vim plugin can be found in Drew Neil's post Registers: The Good, the Bad, and the Ugly Parts
vim  registers  clipboard  cut  copy  paste 
june 2016 by christianmlong
multiple files - How to show search results for all open buffers - Vi and Vim Stack Exchange
Another option is to write a script that generates a file list from :buffers. Per this SO post with a slight tweek we get:

function! BuffersList()
let all = range(0, bufnr('$'))
let res = []
for b in all
if buflisted(b)
call add(res, bufname(b))
return res

function! GrepBuffers (expression)
exec 'vimgrep/'.a:expression.'/ '.join(BuffersList())

command! -nargs=+ GrepBufs call GrepBuffers(<q-args>)

You can now call :GrepBufs <expression> and get the standard :vimgrep output but using the buffers instead.
vim  grep  buffers  search 
april 2016 by christianmlong
regex - How can I make my match non greedy in vim? - Stack Overflow
Instead of .* use .\{-}.


Also, see :help non-greedy
vim  regex  non  greedy 
april 2016 by christianmlong
Multi-line regex support in Vim - Stack Overflow
use \_., which means "match any single character including newline". It's a bit shorter than what you have. See :h /\_..

vim  multi  line  regex 
april 2016 by christianmlong
A noob question, exiting out of Gdiff · Issue #36 · tpope/vim-fugitive
For the past couple of days I've been immediately switching (manually) to the stage buffer after :Gdiff to see what it would be like. I really like it. I just have to train myself to use do instead of dp to stage changes.

My usual flow now:

<C-w><C-h> (Switch to stage buffer.)
gg (Go to the top of the file.)
]c (Go to next change.)
do, if I want to stage the change.
Repeat from Step 4 until I get to the bottom of the file.
If I'm ready to commit, :Gcommit

It feels pretty smooth.
blueyed commented on Mar 15, 2013

you might want to try my "gd" and "gD" mappings then: ",gd" for ":Gdiff" and ",gD" to close the diff (via a function); I have mentioned this above already, but here's a link again:
Peeja commented on Mar 15, 2013

@blueyed How do you write the buffer before closing it?
blueyed commented on Mar 15, 2013

Vim asks me, if I want to write the changes (if there are any).
yevgenko commented on Apr 13, 2013

I've posed the similar question on SO, ended up with the following mapping:

nnoremap <Leader>gD <c-w>h<c-w>c
vim  git  fugitive  workflow  diff  vimdiff  key  mappings 
march 2016 by christianmlong
How to escape a whole string in a : command? - Vi and Vim Stack Exchange
Escaping spaces in vim ex commands. Use a slash to escape the space.

:Glog -Sdefine\ monitoring_setup
vim  fugitive  escape  space  glog  git  ex 
march 2016 by christianmlong
Showing the ASCII value of the current character - Vim Tips Wiki - Wikia
You can learn the ASCII or Unicode value of the character under the cursor by pressing ga in command mode or :as / :ascii on the command line . This displays the value of the current character in decimal, hex and octal. (Think "get ascii.")
vim  unicode  ascii  character  code 
march 2016 by christianmlong
best workflow when using fugitive? : vim
" fugitive git bindings
nnoremap <space>ga :Git add %:p<CR><CR>
nnoremap <space>gs :Gstatus<CR>
nnoremap <space>gc :Gcommit -v -q<CR>
nnoremap <space>gt :Gcommit -v -q %:p<CR>
nnoremap <space>gd :Gdiff<CR>
nnoremap <space>ge :Gedit<CR>
nnoremap <space>gr :Gread<CR>
nnoremap <space>gw :Gwrite<CR><CR>
nnoremap <space>gl :silent! Glog<CR>:bot copen<CR>
nnoremap <space>gp :Ggrep<Space>
nnoremap <space>gm :Gmove<Space>
nnoremap <space>gb :Git branch<Space>
nnoremap <space>go :Git checkout<Space>
nnoremap <space>gps :Dispatch! git push<CR>
nnoremap <space>gpl :Dispatch! git pull<CR>
git  vim  fugitive  plugin  workflow  diff  vimdiff  key  mappings 
march 2016 by christianmlong
Fugitive.vim - exploring the history of a git repository
Browsing past revisions of a file
Browsing past commits
Searching for text in a commit message
git  vim  fugitive  plugin  vimcast  log  grep 
march 2016 by christianmlong
language agnostic - vim search and replace limited to the highlight in visual block mode - Stack Overflow
Include a \%V in the substitution pattern

:'<,'>s/\%V /_/g

Otherwise, it will replace all the spaces on the line, not just those in the visual selection, if the visual selection includes only part of a line. The reason is - 's' is a linewise substitution operation. The \%V is a zero-width atom that matches inside the visual selection only.
vim  highlight  visual  selection  substitution 
march 2016 by christianmlong
chrisbra/vim-diff-enhanced: Better Diff options for Vim
This plugin allows you to make use of the Patience diff algorithm for generating diffs to use with Vim. This needs the git command line tool available.

You can also customize your setup to use any other tool to generated diffs (e.g. mercurial) Read the help on how to configure the plugin accordingly.
vim  diff  patience 
february 2016 by christianmlong
Advanced Vim registers - Arabesque
Numbered registers

The read-only registers 0 through 9 are your “historical record” registers. The register 0 will always contain the most recently yanked text, but never deleted text; this is handy for performing a yank operation, at least one delete operation, and then pasting the text originally yanked with "0p.

The registers 1 through 9 are for deleted text, with "1 referencing the most recently deleted text, "2 the text deleted before that, and so on up to "9.
The small delete register

This read-only register, referenced by "-, stores any text that you deleted or changed that was less than one line in length, unless you specifically did so into some other named register. So if you just deleted three characters with 3x, you’ll find it in here.
vim  register  small  delete  numbered 
january 2016 by christianmlong
cut copy paste - How can I conveniently yank then change small text? - Vi and Vim Stack Exchange
A common text editing situation I run into is to yank a text string and then attempt to replace another string with the one previously yanked.

If I do this on a line Vim generously rotates the registries for me ("1, "2, "…) but with inner text movement you usually get one register and it gets swallowed with the last movement.

So the following example becomes problematic:
vim  small  delete  register 
january 2016 by christianmlong
Can I make Vim also save "small deletions" into register "1? - Vi and Vim Stack Exchange
deleted text is stored initially in register "1 and then shifted up through "2, "3, etc. as further deletions are made is very useful.

However, when a deletion/change removes less than one line of text, it is instead stored in the "- small delete register (with a few exceptions for certain movement commands). If subsequent small deletions are made, that bit of text is lost.

Is it possible to get Vim to store all deletions in register "1?
vim  small  delete  register  numbered 
january 2016 by christianmlong
Numbered register doesn't record most deleted text within a line? - Vi and Vim Stack Exchange
Numbered register 1 contains the text deleted by the most recent delete or change command, unless the command specified another register or the text is less than one line (the small delete register is used then).
vim  delete  numbered  register  small 
january 2016 by christianmlong
vim - Forcing vimdiff to wrap lines? - Stack Overflow
autocmd FilterWritePre * if &diff | setlocal wrap< | endif


:windo set wrap
vimdiff  vim  wrap 
december 2015 by christianmlong
Applying substitutes to a visual block - Vim Tips Wiki - Wikia
If you'd like to apply a substitute, or even any Ex command, to a text region you've selected using visual-blocks (i.e. ctrl-v and move, or ctrl-q in Windows), then you'll be wanting to use Charles Campbell's vis.vim plugin.

Note that applying Ex commands to a simple visual selection is a much simpler process, as is searching in a visual selection (see Tip 438). The vis.vim plugin is useful for applying Ex commands to the area of a blockwise visual selection.
vim  visual  block  substitute 
november 2015 by christianmlong
How to Edit an Existing Vim Macro
Yanking into a register

"qp paste the contents of the register to the current cursor position
I enter insert mode at the begging of the pasted line
^ add the missing motion to return to the front of the line
<Escape> return to visual mode
"qyy yank this new modified macro back into the q register
dd delete the pasted register from the file your editing

Editing the register visually

:let @q=' open the q register
<Cntl-r><Cntl-r>q paste the contents of the q register into the buffer
^ add the missing motion to return to the front of the line
' add a closing quote
<Enter> finish editing the macro
edit  vim  macro 
september 2015 by christianmlong
Vim: Delete buffer without losing the split window - Stack Overflow
bp|bd # will do it.

Details:bp("buffer previous") moves us to a different buffer in the current window (bn would work, too), then bd # ("buffer delete" "alternate file") deletes the buffer we just moved away from. See: help bp, help bd, help alternate-file.
vim  close  buffer  split 
september 2015 by christianmlong
Vim - select text highlighted by search? - Super User
You can use gn in version 7.4 onwards (and gN to go backwards). It replaces the v//e trick.

Search forward for the last used search pattern, like with `n`, and start Visual mode to select the match.

See :help gn or this Vimcast for more information.
vim  select  text  search  highlight 
september 2015 by christianmlong
Commands executed from vim are not recognizing bash command aliases - Stack Overflow
Bash doesn’t load your .bashrc unless it’s interactive. Use

:set shellcmdflag=-ic

to make Vim’s :! shell behave like your command prompt.
vim  bash  alias  function 
september 2015 by christianmlong
Execute current line in bash from vim - Stack Overflow
Sure thing, you can 'write' any content of the current file into the stdin of another program:

:.w !bash

Here . (the part before w) refers to the range of lines you are writing, and . is only the current line. Then you use !bash to write those lines to bash.
vim  current  line  execute  bash 
september 2015 by christianmlong
vimdiff - vim: diff two sections in two files, but not the entire file? - Super User
It sounds like linediff.vim might be what you want: “Perform an interactive diff on two blocks of text”.

You specify each block (line range) with its :Linediff command (e.g. :4,10Linediff, or do a visual selection first, then type :Linediff (which comes out as :'<,'>LineDiff)). The ranges can be from the same file/buffer or different ones. Once you have specified two ranges, it opens a new tab that has two new, diff-mode buffers (in a split) for the specified ranges. You can edit and :w in either of these buffers to update the original ranges. When you are done, :q out of the diff buffers and :LinediffReset to get rid of the range specifiers in the original buffers.
vim  diff  linediff  instructions 
september 2015 by christianmlong
(Vim)diff two subroutines in same file - Stack Overflow
Plugin linediff.vim : Perform an interactive diff on two blocks of text is similar to the one pointed ou by Vincent with some additional features:

has a command to close the opened buffer
seems to work without GUI
insert some visual indication on the original file(s) being diffed.

To use it you perform a visual selection on the first block to diff, enter command :Linediff, and repeat it to the second block. To quit, :LineDiffReset
vim  diff  linediff  plugin 
september 2015 by christianmlong
« earlier      
per page:    204080120160

related tags

absolute  ack  adventure  advice  after  ag  airline  alias  annoyance  annoyances  arrow  ascii  autocomplete  autoread  bash  binding  block  brace  bracket  buffer  buffergator  buffers  camelCase  changes  character  cheatsheet  clipbard  clipboard  close  cmdline-mode  code  colon  colorscheme  column  command  commands  comment  comments  commit  completion  conemu  config  configure  copy  copy_command  count  ctrl-i  ctrl-p  ctrl-r  ctrlp  current  cursor  custom  cut  dark  delete  diff  difftool  directory  distant  docs  dotfiles  down  edit  editing  edting  emacs  empty  enter  errors  escape  evil  ex  example  execute  exit  expand  explanation  file  files  filetype  find  fine-grained  fix  ftplugin  fugitive  function  game  git  github  glog  go_to_line  greedy  grep  gvim  hardcopy  help  helptags  highlight  highlighted  highlighting  history  homebrew  horizontal  html  hub  ide  ideavim  ignore  indent  init.vim  inputrc  install  instructions  integration  ipython  irc  jk  jupyter  key  keybinding  keybindings  keyboard  keymap  keys  killring  learning  light  line  linediff  lines  links  lint  log  mac  macro  manager  map  mappings  markdown  merge  mergetool  mode  modeline  move  movement  multi  multiple  navigate  navigation  neovim  nerdtree  netrw  new  newline  non  nonzero  noremap  number  numbered  numbers  offline  option  options  osx  outline  outliner  parenthesis  paste  pathogen  patience  performance  pipe  plugin  plugins  PostScript  powerline  pylint  python  q:  quality  quicker  quickfix  readline  reddit  reference  regex  register  registers  relative  relativenumber  reload  remapping  repeat  replace  return  review  rhubarb  ruby  sane  screen  script  scriptnames  scroll  search  select  selection  sensible  session  set  setting  setup  shellcheck  shortcuts  silent  silver_searcher  slow  small  snake_case  snippet  sort  space  spaces  spell  spellcheck  spelling  split  sublime_text  substitute  substitution  surround  surrounding  swap  syntax  system  tab  tabpages  tabs  tag  terminal  text  theme  tips  tmux  tpope  trailing  tutorial  two  ultisnips  uncomment  undo  unicode  unimpaired  unsaved  value  vertical  vi  view  vim  vim-ale  vim-qf  vimcast  vimdiff  vimrc  vimscript  visual  visual_block  weechat  whitespace  window  windows  workflow  wrap  yank  yankring  youcompleteme  zeal 

Copy this bookmark: