Changing the practice of leaving and opening the vi (vim) editor?

One of the main differences between vi (vim) and emacs is emacs, which is designed and should be executed at any time without exiting it, where, when the vim fast loading time is set, it is easier to stop working and start editing work, I read that it became the cultural difference between the two editor users.

I am inclined to think that keeping the editor at all times helps in productivity, as you know, something is happening, and you do not need to start again. What are the best tricks and plugins you have found to run one vim session and complete all your tasks?

For example, I am editing Python programs, and then exit the appengine appcfg application and returning. Sometimes exit the current file to open another file. I'm not used to the concept of buffers and tabs yet, but rather run vim in screen sessions if I want to edit multiple files.

+2
source share
7 answers

So, are you using one Vim file per screen session? That sounds good. You really don't need special plugins to easily use multiple files in Vim. Just do

:e /home/project/myfile.py

I installed autochdirin mine .vimrc, which automatically changes the current working directory to any active buffer. So, as soon as you open this file, you can just do

:e myfile2.py
:e myfile3.py

... BTW Vim , , . , ,

:b myfile1.py

, :b 1 , , myfile1.py , , , , . wildmode wildmenu, , , . , ,

:ls

.

, , !

:!ls

. , , , .

+7

:

  • set hidden , . , Vim! . :help windows Vim wiki.

  • , Vim (+clientserver), Vim, "" ( A) Vim ( B). :

    • $ vim --servername WHATEVER, Vim
    • $ vim --remote file.js,

    Vim A, B.

  • . .

+5

: sh, Vim, exit . Vim : vsplit filename : split filename ( ), Esc + Ctrl + w + . . , .

+3

:! . :cd %

bash> vim path/to/ex.c
...
:cd %:h. " move to path/ex/
:!gcc -o %:r % && %:r " compile ex.c into ex and run it

:read, :

:read !ls " read in the names of all the files in the current directory
+1

vim ( linux, ssh), CTRL-z vim. fg, vim.

ctags vim - help tags .

perforce, : http://www.vim.org/scripts/script.php?script_id=240. diff , . :PVDiff, :PFilelog :POpened.

, . /, , vim.


Clipboard

let mapleader=","
" put from clipboard
nmap ,p "*p
" yank to clipboard
nmap ,y "*y

:

" jump to tag in other window
map t :call TagJumpOtherWindow()<cr>
function! TagJumpOtherWindow()
  let cw = expand("<cword>")
  winc p
  exec "tjump " . cw
  let @/ = cw
  normal z.
  winc p
endfunction

:

let mapleader=","
nmap ,x0 :e e:/work/scratch0.txt<CR>
nmap ,x1 :e e:/work/scratch1.txt<CR>
nmap ,x2 :e e:/work/scratch2.txt<CR>
nmap ,x3 :e e:/work/scratch3.txt<CR>
nmap ,x4 :e e:/work/scratch4.txt<CR>
nmap ,x5 :e e:/work/scratch5.txt<CR>
nmap ,x6 :e e:/work/scratch6.txt<CR>
nmap ,x7 :e e:/work/scratch7.txt<CR>
nmap ,x8 :e e:/work/scratch8.txt<CR>
nmap ,x9 :e e:/work/scratch9.txt<CR>

IDE:

function! GetMsdevFile(line)
  let mx = '^\s*\([a-zA-Z_/\.0-9:\- ]*\)'
  let line = matchstr( a:line, mx )
  let file = substitute( line, mx, '\1', '' )
  let file = substitute( line, '\\', '/', '' )
  return file
endfunction

function! GetMsdevLineNumber(line)
  let mx = '^\s*\([a-zA-Z_/\.0-9:\- ]*\)(\(\d\+\))'
  let line = matchstr( a:line, mx )
  let linenumber = substitute( line, mx, '\2', '' )
  return linenumber
endfunction

function! GetMsdevFile2(line)
  let file = expand("%:p:h") . "/" . GetMsdevFile(a:line)
  let file
  return file
endfunction

function! GetMsdevFile2(line)
  let file = expand("%:p:h") . "/../" . GetMsdevFile(a:line)
  let file
  return file
endfunction

function! GotoMsdevMake( thiswin, version )
  exec "cd ".$DIRECTORY."\\.."
  let l = getline(".")
  if a:version==0
      let file = GetMsdevFile(l)
      let linenumber = GetMsdevLineNumber(l)
  elseif a:version==1
      let file = GetMsdevFile2(l)
      let linenumber = GetMsdevLineNumber(l)
  else
      let file = GetMsdevFile3(l)
      let linenumber = GetMsdevLineNumber(l)
  endif
  if a:thiswin==1
    winc p
  endif
  exec "e +" . linenumber. " " . file
  exec "cd -"
endfunction

function! GetGCCFile(line)
  let mx = '^\([a-zA-Z_/\.0-9:\- ]*\):[0-9]\+: .*'
  let line = matchstr( a:line, mx )
  let file = substitute( line, mx, '\1', '' )
  let file = substitute( file, '\\', '/', '' )
  return file
endfunction

function! GetGCCLineNumber(line)
  let mx = '^\([a-zA-Z_/\.0-9:\- ]*\):\([0-9]\+\):.*'
  let line = matchstr( a:line, mx )
  let linenumber = substitute( line, mx, '\2', '' )
  return linenumber
endfunction


function! GotoGCCMake()
  exec "cd ".$DIRECTORY."\\.."
  let l = getline(".")
  let file = GetGCCFile(l)
  let linenumber = GetGCCLineNumber(l)
  winc p
  exec "e +" . linenumber. " " . file
  exec "cd -"
endfunction

function! MakeOut( filename )
  exec ":e " . a:filename
  call MakeBuffer()
  normal zz

endfunction

" use the current buffer into a Visual Studio build output buffer to jump to errors
function! MakeBuffer()
  normal! gg
  exec "/).*error\\|failed"
  nnoremap <buffer> <cr> :call GotoMsdevMake(1, 0)<cr>
  nnoremap <buffer>  :call GotoMsdevMake(1, 1)<cr>
  nnoremap <buffer> o :call GotoMsdevMake(1, 1)<cr>
  " nnoremap <buffer>  :call GotoMsdevMake(0, 0)<cr>
endfunction

" use the current buffer into a GCC build output buffer to jump to errors
function! MakeGCCErr()
  normal! gg
  exec "/: error:"
  nnoremap <buffer> <cr> :call GotoGCCMake()<cr>
  nnoremap <buffer>  :call GotoGCCMake()<cr>
  nnoremap <buffer> o :call GotoGCCMake()<cr>
endfunction

function! MakeGCCOut( filename )
  exec ":e " . a:filename
  call MakeGCCErr()
endfunction

nmap ,mr :call MakeOut( "e:/perforce/branch/obj/release/BuildLog.htm" )<cr>
nmap ,md :call MakeOut( "e:/perforce/branch/obj/debug/BuildLog.htm" )<cr>
nmap ,mm :call MakeBuffer()<CR>
nmap ,mq :call MakeGCCErr()<cr>
+1

I keep one vim window open for several days. Split windows work very nicely on large screens. I also like tabs; I break my breakdowns into one project in a tab, but keep other tabs for my daily plan, my wiki, scratches when they interrupt me. I find tabs easier to use than multiple windows.

0
source

All Articles